diff options
author | Anthony Wang | 2020-09-15 10:55:32 -0500 |
---|---|---|
committer | Anthony Wang | 2020-09-15 10:55:32 -0500 |
commit | 0ee764d6429b375e848f656b02a744df17fa71a2 (patch) | |
tree | 880ea1a99651c5c0da742583369ec057f45f34ff | |
parent | 0de670f3247bb7a465485131711d4cd4fe00d7c0 (diff) |
Add test.r
-rw-r--r-- | test.r | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +# R + +gcd <- function(a, b) { + if (b > 0) return(gcd(b, a %% b)) + else return(a) +} + +cat("test\n") + +N <- 1000 +A <- list() +for (i in 0:N-1) { + A[i+1] <- i # R lists are 1-indexed! +} + +ans <- 0 +for (i in A) { + for (j in A) { + ans <- gcd(i, j) + ans + } +} +cat(ans) |