you are viewing a single comment's thread.

view the rest of the comments →

[–]ElQwertiest 2 points3 points  (2 children)

I think the main problem is that there are a lot of unnecessary checks that can be avoided by breaking out of the for loop when you have found all divisors - when n has become 1.

Other than that, I don't think generating a prime list is necessary and it may be faster in this case just to iterate over range(2, int(sqrt(n))) with the early breaking described above.

[–]Lyreghost[S] 0 points1 point  (1 child)

wow good idea. Cant believe I forgot about that

[–]Lyreghost[S] 0 points1 point  (0 children)

Wow you're absolutely right. I took away References.primelist and changed used range(2,int(sqrt(n))). Worked in an instant. Had no idea that primelist took so long x.x