Totient by mft

def e(n):
\x09n,t=s(n,2,1)
\x09p=3
\x09while n>=p*p:
\x09\x09if n%p<1:n,t=s(n,p,t)
\x09\x09p+=2
\x09print t*(n-1)if n>1 else t
def s(n,p,t):
\x09c=1
\x09while n%p<1:n//=p;t*=p-c;c=0
\x09return n,t
while 1:
\x09try:e(input())
\x09except:break

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page