aboutsummaryrefslogtreecommitdiff
path: root/challenge-153/laurent-rosenfeld/python
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-02-27 14:06:18 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-02-27 14:06:18 +0000
commit18eb47ce3819fc1970cce4e690717ec47168a9fc (patch)
treebb40096958eac7023c97079031da477314e6d4ab /challenge-153/laurent-rosenfeld/python
parent8c1d54d0d2fee25a02ff012e0c7a8eec2b65a886 (diff)
downloadperlweeklychallenge-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.py7
-rw-r--r--challenge-153/laurent-rosenfeld/python/ch-2.py15
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)