Python for loop: “list index out of range” error?

后端 未结 1 580
小鲜肉
小鲜肉 2021-01-29 02:14

I have a code, based on problem 3 from Project Euler: \"The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143?\"

I

相关标签:
1条回答
  • 2021-01-29 02:39

    You probably meant to do:

    for j in range(len(res)):
        for k in range(2,res[j]):
    

    Using for j in res will iterate over res elements.

    0 讨论(0)
提交回复
热议问题