diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-02-27 19:50:10 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-02-27 19:50:10 +0000 |
| commit | 1d8df97db3a52039b8bf6114ccb89f0286baa31b (patch) | |
| tree | 36a5cfaae1a4cb2be6594cdef50b570dcbe15bba /challenge-153/laurent-rosenfeld/lua/ch-2.lua | |
| parent | 6e407bb5e7e014d4fd35fd1852eedaec2408d90e (diff) | |
| download | perlweeklychallenge-club-1d8df97db3a52039b8bf6114ccb89f0286baa31b.tar.gz perlweeklychallenge-club-1d8df97db3a52039b8bf6114ccb89f0286baa31b.tar.bz2 perlweeklychallenge-club-1d8df97db3a52039b8bf6114ccb89f0286baa31b.zip | |
- Added more guest contributions by Laurent Rosenfeld.
Diffstat (limited to 'challenge-153/laurent-rosenfeld/lua/ch-2.lua')
| -rw-r--r-- | challenge-153/laurent-rosenfeld/lua/ch-2.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-153/laurent-rosenfeld/lua/ch-2.lua b/challenge-153/laurent-rosenfeld/lua/ch-2.lua new file mode 100644 index 0000000000..de67df223f --- /dev/null +++ b/challenge-153/laurent-rosenfeld/lua/ch-2.lua @@ -0,0 +1,19 @@ +function is_factorion(fact, num) + sum = 0 + i = num + while i > 0 do + sum = sum + fact[ 1 + i % 10] + i = math.floor(i / 10) + end + return num == sum +end + +fact = {1} +for n = 1, 10 do + table.insert(fact, n * fact[n]) +end +for j = 1, 50000 do + if is_factorion(fact, j) then + print(j) + end +end |
