summaryrefslogtreecommitdiff
path: root/Problem34.py
diff options
context:
space:
mode:
authorJoshua Drake <joshua.drake@ditchwitch.com>2023-04-07 08:13:49 -0500
committerJoshua Drake <joshua.drake@ditchwitch.com>2023-04-07 08:13:49 -0500
commit1161f9a034de06a63538e3a9a0b7717098c744d9 (patch)
tree55bb842b2daa4f096eb7916a8d3630426fc1c376 /Problem34.py
Initial CommitHEADmaster
Diffstat (limited to 'Problem34.py')
-rw-r--r--Problem34.py20
1 files changed, 20 insertions, 0 deletions
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)