Add test.r

This commit is contained in:
Anthony Wang 2020-09-15 10:55:32 -05:00
parent 0de670f324
commit 0ee764d642
Signed by: a
GPG key ID: 6FD3502572299774

22
test.r Normal file
View file

@ -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)