
-----------------------------------
KONjbnj
Thu Apr 14, 2005 8:28 am

Fibonacci help
-----------------------------------
Write a program which calculates the Fibonacci series. Your program should print out the first 25 fibonacci numbers.

That's what I'm supposed to do, but I can't find a way to do it with variables instead of using put statements.

-----------------------------------
Martin
Thu Apr 14, 2005 8:33 am


-----------------------------------
Well, the first two numbers of the Fibonacci sequence are 1 and 1

The n'th term of the Fibonacci sequence is simply the sum of the previous two terms. That is, 

F(1) = 1
F(2) = 1
F(3) = F(1) + F(2) = 2
F(4) = F(2) + F(3) = 3
...
F(N) = F(N-2) + F(N-1)

This problem lends itself very well to using an array and a for loop.

-----------------------------------
KONjbnj
Thu Apr 14, 2005 8:38 am


-----------------------------------
I know that for Fibonacci you add the last two numbers to get it.

Sorry, but I don't get what you said >_