From 1161f9a034de06a63538e3a9a0b7717098c744d9 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Fri, 7 Apr 2023 08:13:49 -0500 Subject: Initial Commit --- Problem34.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Problem34.py (limited to 'Problem34.py') diff --git a/Problem34.py b/Problem34.py new file mode 100644 index 0000000..07d7146 --- /dev/null +++ b/Problem34.py @@ -0,0 +1,20 @@ +#completed on 9/13/2021 15:26 +def factorial(n): + for x in range(2,n): + n = n*x + return n +def factorialSum(n): + m,sum = str(n),0 + for x in range(0,len(m)): + if int(m[x]) == 0: + sum += 1 + else: + sum += factorial(int(m[x])) + if sum > n: return False + if sum == n: return True + else: return False +sum = 0 +for x in range(10,2540161,1): + if factorialSum(x) == True: + sum += x +print("Solution is:" ,sum) -- cgit v1.2.3