diff options
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) |
