We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1d22368 + 2f1ed0d commit a343f54Copy full SHA for a343f54
euler-totient-in_python.py
@@ -0,0 +1,29 @@
1
+# A simple Python3 program
2
+# to calculate Euler's
3
+# Totient Function
4
+
5
+# Function to return
6
+# gcd of a and b
7
+def gcd(a, b):
8
9
+ if (a == 0):
10
+ return b
11
+ return gcd(b % a, a)
12
13
+# A simple method to evaluate
14
+# Euler Totient Function
15
+def phi(n):
16
17
+ result = 1
18
+ for i in range(2, n):
19
+ if (gcd(i, n) == 1):
20
+ result+=1
21
+ return result
22
23
+# Driver Code
24
+for n in range(1, 11):
25
+ print("phi(",n,") = ",
26
+ phi(n), sep = "")
27
28
+# This code is contributed
29
+# by Smitha
0 commit comments