aboutsummaryrefslogtreecommitdiff
path: root/challenge-008/zapwai/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-008/zapwai/python/ch-1.py')
-rw-r--r--challenge-008/zapwai/python/ch-1.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-008/zapwai/python/ch-1.py b/challenge-008/zapwai/python/ch-1.py
new file mode 100644
index 0000000000..097dad9c94
--- /dev/null
+++ b/challenge-008/zapwai/python/ch-1.py
@@ -0,0 +1,15 @@
+def is_perfect(num):
+ divs = []
+ for i in range(1, int(num/2) + 1):
+ if num % i == 0:
+ divs.append(i)
+ return (sum(divs) == num);
+
+def perfects() :
+ for i in range(2, 15):
+ num = pow(2, i - 1) * (pow(2,i) - 1);
+ if is_perfect(num):
+ print(num,"", end='')
+
+perfects();
+print()