Fibonacci without Recursion
Andy talks about Fibonacci sequences:
"Honestly though aside from the beauty of the sequence what practical purpose does calculating the sequence serve? Anybody out there have an answer to that other than "it a good way to show/test recursion"? I'll give public props to the first commentor who gives me one real-world practical use for calculating the sequence."
To begin -- go get Fibonacci without recursion via the simple function like:
function fun1(n) { var f; var j; f = (1 + Math.pow(5, 0.5)) / 2; g = 1 - f; return (Math.pow(f,(n + 1)) - Math.pow(g,(n + 1))) / Math.pow(5, 0.5); }
Real world examples usually come from the building industry. Like, er, you have 0 and 00 blocks to accomplish 1*N road/wall, etc. You have to calculate how. Besides, fibonacci problem is always a good interview question.
Monday, April 25, 2005 10:13 PM