Add Lua code

This commit is contained in:
Anthony Wang 2021-12-08 12:40:12 -06:00
parent 9e38c72d03
commit f6c080fd9f
Signed by: a
GPG Key ID: BC96B00AEC5F2D76
2 changed files with 26 additions and 1 deletions

2
run.sh
View File

@ -59,4 +59,4 @@ echo Lisp
hyperfine "ecl --shell test.lisp"
echo Lua
hyperfine "lua test.lua"

25
test.lua Normal file
View File

@ -0,0 +1,25 @@
-- Lua
function gcd(a, b)
if b > 0 then
return gcd(b, a % b);
else
return a;
end
end
print("test");
N = 1000;
A = {};
for i = 1, N do
A[i] = i - 1;
end
ans = 0;
for _, i in ipairs(A) do
for _, j in ipairs(A) do
ans = gcd(i, j) + ans;
end
end
print(ans);