diff options
| author | Márton Polgár <37218286+2colours@users.noreply.github.com> | 2022-02-21 18:24:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-21 18:24:51 +0100 |
| commit | 1b528a9e77709d3d6159c9bf4e8066a735049797 (patch) | |
| tree | 47f1cc98c548411026748c99cd0997ff0988681a /challenge-153/abigail/python/ch-2.py | |
| parent | 1c39414e90bfa4093a8443f28c4d8e00a6809363 (diff) | |
| parent | e1575d77a4181187d7a30e2ac0df6679f4e2bd43 (diff) | |
| download | perlweeklychallenge-club-1b528a9e77709d3d6159c9bf4e8066a735049797.tar.gz perlweeklychallenge-club-1b528a9e77709d3d6159c9bf4e8066a735049797.tar.bz2 perlweeklychallenge-club-1b528a9e77709d3d6159c9bf4e8066a735049797.zip | |
Merge branch 'manwar:master' into branch-for-challenge-153
Diffstat (limited to 'challenge-153/abigail/python/ch-2.py')
| -rw-r--r-- | challenge-153/abigail/python/ch-2.py | 28 |
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) |
