Timeline for More efficient solution for Project Euler #2 (sum of Fibonacci numbers under 4 million)
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 17, 2014 at 17:38 | history | migrated | from stackoverflow.com (revisions) | ||
| Jan 17, 2014 at 14:22 | comment | added | Madison May | Fair point -- it's your best friend and your worst enemy. | |
| Jan 17, 2014 at 6:37 | comment | added | Steinar Lima | @MadisonMay ...which may cause uncaught overflows (I don't remember where I read it) | |
| Jan 17, 2014 at 5:07 | comment | added | Madison May | In the event that the OP does run into a max recursion depth issue, sys.setrecursionlimit(n) is your friend. | |
| Jan 17, 2014 at 5:01 | comment | added | senshin | Right, it certainly isn't an issue here, but I figured it was worth mentioning, since (if I remember right) some of the later Project Euler problems do require very deep recursions if implemented recursively. | |
| Jan 17, 2014 at 5:00 | comment | added | Madison May | Yup, definitely a concern. I didn't now how much detail I should go into there, but the python maximum recursion depth is definitely a problem that you could run into. | |
| Jan 17, 2014 at 4:59 | comment | added | senshin | Recursion is not always a good solution in Python, however, because Python doesn't implement tail recursion and, more generally, isn't designed to support recursive algorithms that are equally well-handled via iteration. If you try to call fibonacci(0, 1, 1000), you'll hit a RuntimeError because you'll have exceeded the maximum recursion depth. Of course, the 1000th Fibonacci number is much, much larger than 4 million, but this is still an issue worth keeping in mind. | |
| Jan 17, 2014 at 4:51 | history | answered | Madison May | CC BY-SA 3.0 |