Fibonacci Sequence

Ok so I just can't wrap my head around a way to do this. I've been sitting here for awhile and I'm stuck
You can do this with a loop and three variables!

You add the first two numbers, which create a third, you then add the sencond number to the third, and so on.

You need to start with 0 and 1.

0 + 1 = 1;
1 + 1 = 2;
1 + 2 = 3;
2 + 3 = 5;
3 + 5 = 7;
...And so on.

Variables: lowNumber, highNumber, tempNumber.
Oh wow! When you actually write it out like that, it becomes so easy. I was wreckin my head trying to figure this out, and I was trying to stay in 2 variables but it wasnt happening. Thanks!
ahaha no prob. I thought it looked hard, from the way wiki had the formula set out, until I realised what it was doing!

EDIT:
I've never been good at looking at formula, lol.
Last edited on
Lynx876 wrote:
3 + 5 = 7;


*giggle*

It's like you were mixing up Fibonacci and primes.
Last edited on
ahahaha! Yeah, I'm a teacher of math ;)

...I suck at primes, I had to write a C++ add to find out what they were!
Now that we're on the topic of primes...
http://www.cplusplus.com/forum/beginner/60298/
:D
Topic archived. No new replies allowed.