aboutsummaryrefslogtreecommitdiff
path: root/challenge-153/abigail/python/ch-2.py
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-02-23 12:01:46 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-02-23 12:01:46 +0000
commit1f0b1bb7c4547e1a90c6a9e5e3e917896cec09f7 (patch)
tree3367cd541740d269c24d7c5fd77dcf97b335e1b8 /challenge-153/abigail/python/ch-2.py
parent6969759d9c3f60d28741151faf35d479fe671cf0 (diff)
parentb44719f171b42ef306e7e50933125b7b1371b38d (diff)
downloadperlweeklychallenge-club-1f0b1bb7c4547e1a90c6a9e5e3e917896cec09f7.tar.gz
perlweeklychallenge-club-1f0b1bb7c4547e1a90c6a9e5e3e917896cec09f7.tar.bz2
perlweeklychallenge-club-1f0b1bb7c4547e1a90c6a9e5e3e917896cec09f7.zip
vi ch-2Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-153/abigail/python/ch-2.py')
-rw-r--r--challenge-153/abigail/python/ch-2.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-153/abigail/python/ch-2.py b/challenge-153/abigail/python/ch-2.py
new file mode 100644
index 0000000000..693eeffe7f
--- /dev/null
+++ b/challenge-153/abigail/python/ch-2.py
@@ -0,0 +1,28 @@
+#!/usr/local/bin/python3
+
+#
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-153
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+
+fac = [1] * 10
+for n in range (1, 10):
+ fac [n] = n * fac [n - 1]
+
+for line in fileinput . input ():
+ num = int (line)
+ sum = 0
+ n = num
+ while n > 0:
+ sum = sum + fac [n % 10]
+ n = n // 10
+
+ if num == sum:
+ print (1)
+ else:
+ print (0)