-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler254.py
More file actions
63 lines (53 loc) · 1.33 KB
/
Copy patheuler254.py
File metadata and controls
63 lines (53 loc) · 1.33 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#gets the sum of the factorials of the characters of an integer.
def f(num):
a = str(num)
digit_map = map(int, a)
num_list = list(digit_map)
list_sum = 0
for i in range(0, len(num_list)):
list_sum = list_sum + factorial(num_list[i])
return list_sum
#gets the sum of the characters of the output of f().
def sf(num):
b = str(f(num))
digit_map_1 = map(int, b)
num_list_1 = list(digit_map_1)
the_sum = 0
for i in range(0, len(num_list_1)):
the_sum = the_sum + num_list_1[i]
return the_sum
#to get the factorial of a number.
def factorial(b):
if b == 0:
fact = 1
else:
if b-1 > 0:
n = b-1
else:
n = b
fact = b * n
while n > 0:
if n != b-1:
fact = fact * n
n = n-1
return fact
def g(c):
guess = 0
while sf(guess) != c or guess == 0:
guess = guess + 1
return guess
def sg(c):
b = str(g(c))
digit_map_2 = map(int, b)
num_list_2 = list(digit_map_2)
total = 0
for i in range(0, len(num_list_2)):
total = total + num_list_2[i]
return total
def summation(n, m):
the_sum = 0
for i in range(1, n+1):
the_sum = the_sum + sg(i)
return the_sum % m
print (summation(20, 1000000))
print(g(3))