Project Euler #3: Largest prime factor

  • + 0 comments

    below code in python passed 1st sample test case but failed hidden test case, could anyone help:

    mport sys def factor(n): l=[] for i in range(2,n+1): if n%i==0: l.append(i) for j in l: for k in range(2, j): if (j % k) != 0: continue else: l.remove(j) break #print(j,k) #print(l) l.sort(reverse=True) return(l[0])

    t = int(input().strip()) for a0 in range(t): n = int(input().strip()) print(factor(n))