From 0ee764d6429b375e848f656b02a744df17fa71a2 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Tue, 15 Sep 2020 10:55:32 -0500 Subject: Add test.r --- test.r | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test.r diff --git a/test.r b/test.r new file mode 100644 index 0000000..6ab5ff9 --- /dev/null +++ b/test.r @@ -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) -- cgit v1.2.3-70-g09d2