You are viewing a single comment's thread. Return to all comments →
from math import factorial
def gcd(p,q): while q != 0: p, q = q, p%q return p def is_coprime(x, y): return gcd(x, y) == 1
c=list(map(int,input().rstrip().split())) d=[] n= factorial(c[0]) b= 1 for i in range(n-1,2,-1): if (is_coprime(n,i)==1): b+=1 break d.append(i)
print(d[len(d)-1])
this code is working for smaller values but with the inputs of the problem it is showing time out please help
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #248: Numbers for which Euler’s totient function equals 13!
You are viewing a single comment's thread. Return to all comments →
from math import factorial
def gcd(p,q): while q != 0: p, q = q, p%q return p def is_coprime(x, y): return gcd(x, y) == 1
c=list(map(int,input().rstrip().split())) d=[] n= factorial(c[0]) b= 1 for i in range(n-1,2,-1): if (is_coprime(n,i)==1): b+=1 break d.append(i)
print(d[len(d)-1])
this code is working for smaller values but with the inputs of the problem it is showing time out please help