-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem_034.py
More file actions
39 lines (31 loc) · 956 Bytes
/
Copy pathproblem_034.py
File metadata and controls
39 lines (31 loc) · 956 Bytes
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
# Date: 2025.07.20
# Answer: 40730
import math
from itertools import permutations
import time
def get_digits(value):
list_digits = list(str(value))
return list_digits
def get_sum(list):
sum = 0
for item in list:
sum += math.factorial(int(item))
return sum
if __name__ == "__main__":
start_time = time.perf_counter()
count = 0
value = 3
while value < 10000000000:
print(f"value: {value} sum: {sum} count: {count} ", end='\r')
list_digits = get_digits(value)
sum = get_sum(list_digits)
if(value == sum):
count+=1
print(f"value: {value} sum: {sum} count: {count}")
if(sum > value):
value = int(round(value+5.1,-1))
continue
value += 1
cur_time = time.perf_counter()
elapsed_time = cur_time - start_time
print(f"Function execution time: {elapsed_time:.6f} seconds")