aboutsummaryrefslogtreecommitdiff
path: root/challenge-175/laurent-rosenfeld/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-175/laurent-rosenfeld/python/ch-2.py')
-rw-r--r--challenge-175/laurent-rosenfeld/python/ch-2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-175/laurent-rosenfeld/python/ch-2.py b/challenge-175/laurent-rosenfeld/python/ch-2.py
new file mode 100644
index 0000000000..d465124687
--- /dev/null
+++ b/challenge-175/laurent-rosenfeld/python/ch-2.py
@@ -0,0 +1,13 @@
+import math
+
+cache = [0] * 10000
+
+def is_perfect_totient (n):
+ tot = 0
+ for i in range(1, n):
+ if (math.gcd(n, i) == 1):
+ tot += 1
+
+​ sum = tot + cache[tot] ​ cache[n] = sum ​ return n == sum
+​
+i = 1 ​ count = 0 ​ while count < 20: ​ if isperfecttotient(i): ​ print(i, end = ” “) ​ count += 1 ​ i += 1 ​ print(” “)