diff options
| author | Dave Jacoby <jacoby.david@gmail.com> | 2021-07-12 10:48:31 -0400 |
|---|---|---|
| committer | Dave Jacoby <jacoby.david@gmail.com> | 2021-07-12 10:48:31 -0400 |
| commit | 34a6514808c066bee4e7f3d7d8bdeb67db056392 (patch) | |
| tree | 05d0e268045ef3d6f971ec0e0c3eb1a48bdb7edd /challenge-089/stuart-little/lua | |
| parent | b59f8f4008bb8ec491a9e89f097f04ce54aed4c0 (diff) | |
| parent | 1aa7b6eaba2a58fc1ef0612373e3aed6b61f345d (diff) | |
| download | perlweeklychallenge-club-34a6514808c066bee4e7f3d7d8bdeb67db056392.tar.gz perlweeklychallenge-club-34a6514808c066bee4e7f3d7d8bdeb67db056392.tar.bz2 perlweeklychallenge-club-34a6514808c066bee4e7f3d7d8bdeb67db056392.zip | |
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-089/stuart-little/lua')
| -rwxr-xr-x | challenge-089/stuart-little/lua/ch-1.lua | 17 | ||||
| -rwxr-xr-x | challenge-089/stuart-little/lua/ch-2.lua | 7 |
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 |
