diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-07-17 00:26:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-17 00:26:19 +0100 |
| commit | 10efa0029dfcfbcc038a5e85052fd352c8387a03 (patch) | |
| tree | e5c13edb19e9b7346043457dc57c0e86c502ea78 /challenge-085/stuart-little/lua/ch-2.lua | |
| parent | 1eec60b6cab6562a5eef76a369c0abe704d45f82 (diff) | |
| parent | d9cb00dab85f052c8df9c09030e661fb01fae4d5 (diff) | |
| download | perlweeklychallenge-club-10efa0029dfcfbcc038a5e85052fd352c8387a03.tar.gz perlweeklychallenge-club-10efa0029dfcfbcc038a5e85052fd352c8387a03.tar.bz2 perlweeklychallenge-club-10efa0029dfcfbcc038a5e85052fd352c8387a03.zip | |
Merge pull request #4533 from stuart-little/stuart-little_085_lua
1st commit on 085_lua
Diffstat (limited to 'challenge-085/stuart-little/lua/ch-2.lua')
| -rwxr-xr-x | challenge-085/stuart-little/lua/ch-2.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-085/stuart-little/lua/ch-2.lua b/challenge-085/stuart-little/lua/ch-2.lua new file mode 100755 index 0000000000..fb088b292b --- /dev/null +++ b/challenge-085/stuart-little/lua/ch-2.lua @@ -0,0 +1,14 @@ +#!/usr/bin/env lua + +-- run <script> <number> + +for i=2,arg[1] do + local base = math.floor(math.exp(math.log(arg[1])/i)) + for j=0,1 do + if (base+j)^i==tonumber(arg[1]) then + print(("%d: %d = %d ^ %d"):format(1,arg[1],base+j,i)) + os.exit() + end + end +end +print(0) |
