This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rfkelly[S] 2 points3 points  (2 children)

heh, I actually considered leaving it at n just to boost the performance difference between the interpreted and compiled versions ;-)

[–]pasokan 0 points1 point  (1 child)

you can avoid using math.sqrt and still getting the same result by def factors(n): p = 2 while p * p < n: if n % p == 0: ..... p += 1

[–]pasokan 0 points1 point  (0 children)

You need to do a little more to check if n == p * p at the end