On 5/7/2014 8:39 PM, C Smith wrote:
I see. Thanks that is exactly what I was looking for. Would your
example be an instance of an object-oriented approach,
compartmentalizing things into functions?

One of the fun parts of Project Euler is using mathematical analysis and other tricks to improve your algorithm.

You have a nice, general Fibonacci number generator, but you can use a less general function to increase efficiency [1]. In this case, it doesn't matter--your initial solution was fast enough--but you'll soon be solving problems where the most general solution fails to be fast enough.

[1] Your code is calculating about twice as many Fibonacci numbers as it needs to. See if you can create a way to calculate Fib(n+2) from Fib(n).

--
Neil Cerutti

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to