From f6c080fd9f22141085046b3ead643563648a1276 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Wed, 8 Dec 2021 12:40:12 -0600 Subject: Add Lua code --- run.sh | 2 +- test.lua | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test.lua diff --git a/run.sh b/run.sh index 5bb14a5..fc5986f 100755 --- a/run.sh +++ b/run.sh @@ -59,4 +59,4 @@ echo Lisp hyperfine "ecl --shell test.lisp" echo Lua - +hyperfine "lua test.lua" diff --git a/test.lua b/test.lua new file mode 100644 index 0000000..3d26a40 --- /dev/null +++ b/test.lua @@ -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); -- cgit v1.2.3-70-g09d2