Timeline for Project Euler Problem 21 in Python: Summing amicable numbers
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 29, 2020 at 0:44 | review | Suggested edits | |||
Jun 29, 2020 at 1:26 | |||||
Sep 25, 2018 at 13:50 | vote | accept | RKJ | ||
Sep 25, 2018 at 13:50 | |||||
Aug 30, 2018 at 16:14 | comment | added | Graipher |
@AJNeufeld For limit = 10000 yes. I tested my code with limit = 250 , which splits the example pair, to get the behavior I consider the best interpretation of the challenge rules.
|
|
Aug 30, 2018 at 16:11 | comment | added | AJNeufeld |
The question is vague as to whether or not to include a if b is beyond the limit. Curiosity got the better of me. There is no amicable pair (a,b) where a <= limit and b > limit.
|
|
Aug 30, 2018 at 16:04 | comment | added | Graipher |
@AJNeufeld I specifically fixed it so that I do include a and don't include b in that case. a is still an amicable number, it's amicable pair is just greater than the limit. You are right on the running total, though. But since the timing is well under a second I stopped optimizing...
|
|
Aug 30, 2018 at 15:59 | comment | added | AJNeufeld |
I think you could be getting the wrong answer. If there exists an amicable pair a <= limit , b > limit , you will add a to the total, where as the original solution adds neither. You could fixed this with:if b < a and sum_div(b) == a: yield a; yield b . The summing the output of a generator is unnecessary, and will slow things down. For faster code, use total = 0 total += a + b and return total .
|
|
Aug 30, 2018 at 12:28 | history | edited | Graipher | CC BY-SA 4.0 |
deleted 348 characters in body; deleted 16 characters in body
|
Aug 30, 2018 at 8:08 | history | edited | Graipher | CC BY-SA 4.0 |
added 44 characters in body
|
Aug 30, 2018 at 8:00 | history | edited | Graipher | CC BY-SA 4.0 |
added 1011 characters in body
|
Aug 30, 2018 at 7:45 | history | answered | Graipher | CC BY-SA 4.0 |