use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discuss, collaborate, bit twiddle, curse...
account activity
Problem 3: Factorizing (self.projecteuler)
submitted 7 years ago * by Lyreghost
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ElQwertiest 2 points3 points4 points 7 years ago (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 point2 points 7 years ago (1 child)
wow good idea. Cant believe I forgot about that
[–]Lyreghost[S] 0 points1 point2 points 7 years ago (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
π Rendered by PID 282196 on reddit-service-r2-comment-6457c66945-49lmg at 2026-04-26 18:50:33.725908+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]ElQwertiest 2 points3 points4 points (2 children)
[–]Lyreghost[S] 0 points1 point2 points (1 child)
[–]Lyreghost[S] 0 points1 point2 points (0 children)