aboutsummaryrefslogtreecommitdiff
path: root/challenge-089
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-089')
-rwxr-xr-xchallenge-089/stuart-little/lua/ch-1.lua17
-rwxr-xr-xchallenge-089/stuart-little/lua/ch-2.lua7
2 files changed, 24 insertions, 0 deletions
diff --git a/challenge-089/stuart-little/lua/ch-1.lua b/challenge-089/stuart-little/lua/ch-1.lua
new file mode 100755
index 0000000000..2bfb91aee6
--- /dev/null
+++ b/challenge-089/stuart-little/lua/ch-1.lua
@@ -0,0 +1,17 @@
+#!/usr/bin/env lua
+
+-- run <script> <number>
+
+function gcd(a,b)
+ local lg,sml = math.max(math.abs(a),math.abs(b)),math.min(math.abs(a),math.abs(b))
+ if sml==0 then return lg end
+ return gcd(sml,lg%sml)
+end
+
+local sm=0
+for i=1,arg[1]-1 do
+ for j=i+1,arg[1] do
+ sm=sm+gcd(i,j)
+ end
+end
+print(sm)
diff --git a/challenge-089/stuart-little/lua/ch-2.lua b/challenge-089/stuart-little/lua/ch-2.lua
new file mode 100755
index 0000000000..af8bfbccf3
--- /dev/null
+++ b/challenge-089/stuart-little/lua/ch-2.lua
@@ -0,0 +1,7 @@
+#!/usr/bin/env lua
+
+-- run <script>
+
+for _,r in ipairs({{2,7,6},{9,5,1},{4,3,8}}) do
+ print(table.unpack(r))
+end