Project Euler #29: Distinct powers

  • + 1 comment
    L=[]
    N=int(input(""))
    if N>=2 and N<=10**5:
        for a in range(2,N+1):
            for b in range(2,N+1):
                c=a**b
                if c not in L:
                    L.append(c)
                else:
                    pass
        print(len(L))
    else:
        pass
    
    • + 0 comments

      I used the same principle in my code. But this only passes the first six test cases - timing out on the rest :-(