blob: 693eeffe7fca1a97f2b094155d09afb5818038c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)
|