aboutsummaryrefslogtreecommitdiff
path: root/challenge-109/abigail/python/ch-1.py
diff options
context:
space:
mode:
author冯昶 <seaker@qq.com>2021-04-26 14:38:42 +0800
committer冯昶 <seaker@qq.com>2021-04-26 14:38:42 +0800
commit8e8759a0d1ac0cb3c7e329b52fd3a242eb1781f7 (patch)
tree124e60bc8400206b1b5bd31e5a821e3e8c5f026d /challenge-109/abigail/python/ch-1.py
parentaf66a71f6313aa7102dff899c27ea0958e0b83d2 (diff)
parent1ff197d81f941c3dd35d77bec8a0326807e8d2b1 (diff)
downloadperlweeklychallenge-club-8e8759a0d1ac0cb3c7e329b52fd3a242eb1781f7.tar.gz
perlweeklychallenge-club-8e8759a0d1ac0cb3c7e329b52fd3a242eb1781f7.tar.bz2
perlweeklychallenge-club-8e8759a0d1ac0cb3c7e329b52fd3a242eb1781f7.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-109/abigail/python/ch-1.py')
-rw-r--r--challenge-109/abigail/python/ch-1.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/challenge-109/abigail/python/ch-1.py b/challenge-109/abigail/python/ch-1.py
new file mode 100644
index 0000000000..f9e51a0897
--- /dev/null
+++ b/challenge-109/abigail/python/ch-1.py
@@ -0,0 +1,39 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py [plain | compute]
+#
+
+import sys
+
+COUNT = 20
+PLAIN = 0
+COMPUTE = 1
+
+def divisor_sum (n):
+ sum = 0
+ for i in range (2, n / 2 + 1):
+ if n % i == 0:
+ sum = sum + i
+ return (sum)
+
+type = PLAIN
+
+if len (sys . argv) > 1 and sys . argv [1] == "compute":
+ type = COMPUTE
+
+
+if type == PLAIN:
+ print ("0, 0, 0, 2, 0, 5, 0, 6, 3, 7, 0, 15, 0, 9, 8, 14, 0, 20, 0, 21")
+
+
+if type == COMPUTE:
+ for n in range (1, COUNT + 1):
+ if n > 1:
+ print (", ", end = '')
+ print (divisor_sum (n), end = '')
+ print ("")