diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-02-27 14:06:18 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-02-27 14:06:18 +0000 |
| commit | 18eb47ce3819fc1970cce4e690717ec47168a9fc (patch) | |
| tree | bb40096958eac7023c97079031da477314e6d4ab /challenge-153/laurent-rosenfeld/python | |
| parent | 8c1d54d0d2fee25a02ff012e0c7a8eec2b65a886 (diff) | |
| download | perlweeklychallenge-club-18eb47ce3819fc1970cce4e690717ec47168a9fc.tar.gz perlweeklychallenge-club-18eb47ce3819fc1970cce4e690717ec47168a9fc.tar.bz2 perlweeklychallenge-club-18eb47ce3819fc1970cce4e690717ec47168a9fc.zip | |
- Added more guest contributions by Laurent Rosenfeld.
Diffstat (limited to 'challenge-153/laurent-rosenfeld/python')
| -rw-r--r-- | challenge-153/laurent-rosenfeld/python/ch-1.py | 7 | ||||
| -rw-r--r-- | challenge-153/laurent-rosenfeld/python/ch-2.py | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-153/laurent-rosenfeld/python/ch-1.py b/challenge-153/laurent-rosenfeld/python/ch-1.py new file mode 100644 index 0000000000..159f8db710 --- /dev/null +++ b/challenge-153/laurent-rosenfeld/python/ch-1.py @@ -0,0 +1,7 @@ +fact = 1 +left_fact = 1 + +for n in range (1, 11): + print(left_fact) + fact = fact * n + left_fact = left_fact + fact diff --git a/challenge-153/laurent-rosenfeld/python/ch-2.py b/challenge-153/laurent-rosenfeld/python/ch-2.py new file mode 100644 index 0000000000..6468fa9f27 --- /dev/null +++ b/challenge-153/laurent-rosenfeld/python/ch-2.py @@ -0,0 +1,15 @@ +fact = [1] * 10 +for n in range (1, 10): + fact[n] = n * fact[n - 1] + +def is_factorion (input): + sum = 0 + n = str(input) + for i in range (0, len(n)): + sum = sum + fact[int(n[i])] + + return input == sum + +for n in range(1, 50000): + if is_factorion(n): + print(n) |
