I want to get the euclidean totient, but when i call the ggt(x,z1)
in totient()
it returns None
.
Any idea what the problem is?
Shouldn't ggt
return the value to the totitent()
?
#!/usr/bin/python3
def ggt(a, b):
if a > b:
while b!=0:
c = a % b
a = b
b = c
return a
else:
ggt(b,a)
def totient():
while True:
try:
z1 = int(input('insert number '))
break
except:
print("Not a integer!")
continue
counter = 1
for x in range(2,z1):
cache = ggt(x,z1)
if (cache == 1): # <-- this returns None
counter += 1
print("phi(%d)" % (counter))
totient()