summaryrefslogtreecommitdiff
path: root/Problem21.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 /Problem21.py
Initial CommitHEADmaster
Diffstat (limited to 'Problem21.py')
-rw-r--r--Problem21.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Problem21.py b/Problem21.py
new file mode 100644
index 0000000..42632be
--- /dev/null
+++ b/Problem21.py
@@ -0,0 +1,17 @@
+def amicablesum(n):
+ sum = 0
+ sum2 = 0
+ for x in range(1,int(n/2)+1):
+ if n%x==0:
+ sum+=x
+ for x in range(1, int(sum/2)+1):
+ if sum%x==0:
+ sum2 +=x
+ if (n!=sum)and(sum2 == n): return n
+ else: return 0
+sumcounter = 0
+for x in range(1,10000):
+ sumcounter += amicablesum(x)
+ print(sumcounter)
+print("final sum of amicable numbers is:" ,sumcounter)
+