If you want to calculate the nth term of the fibonacci sequence
without calculating all the preceding terms, the closed form solution
would be ideal. But for this problem, you actually want to walk the
full fibonacci sequence in order, so that really isn't appropriate.

On Feb 9, 4:47 pm, Kevin Wright <[email protected]> wrote:
> import math._
> val phi = (1+sqrt(5))/2.0d
> def fib(n: Int) = round(pow(phi,n)/sqrt(5))
>
> (0 to 10) map (fib)
> // = Vector(0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55)

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to