3 ms·
> (Our question is: given that F(n) = F(n-1) + F(n+2) and F(1) = 1 and F(0) = 1, write a naive function in your favorite programming language to calculate F(n).
by Natsu 15y ago
> (Our question is: given that F(n) = F(n-1) + F(n+2) and F(1) = 1 and F(0) = 1, write a naive function in your favorite programming language to calculate F(n). And people can't do it!)
If you have that F(n+2) in there, it gets a little harder than just giving you the Fibonacci numbers.
- jrockway 15y agoThat would be a typo :)
- jurjenh 15y agoDamn... and here I am trying to refactor it... I even got as far as: F(n) = F(n-1) + F(n+2) -> F(n) + F(n-3) = F(n-2) --> F(n) = F(n-2) - F(n-3) so with F(0) = 0 and F(1) = 1 it gives F(3) = 1, but then you kinda need to figure out what F(2) may be... Oh well, on to the next problem then.