fabonacci numbers - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# fabonacci numbers

Posts: 2Member
[b][red]This message was edited by jcherring4 at 2007-3-12 2:25:42[/red][/b][hr]
Look guys i am new to this and got myself behind on this thing can i beg for some help here please help me with this program!!!!!
this is what the display should look like

1. Display the first 25 Fibonacci numbers
2. Display the first 50 Fibonacci numbers
3. Display the first 75 Fibonacci numbers
4. Display the first 125 Fibonacci numbers
5. Display the first 200 Fibonacci numbers

hit me back soon as you can please!
help me with a starting point
read the material that i should have but cant get a start
a sample program could help if
that is not too much to ask
i am in a bind here

• Posts: 6,349Member
: [b][red]This message was edited by jcherring4 at 2007-3-12 2:25:42[/red][/b][hr]
: Look guys i am new to this and got myself behind on this thing can i beg for some help here please help me with this program!!!!!
: this is what the display should look like
:
: 1. Display the first 25 Fibonacci numbers
: 2. Display the first 50 Fibonacci numbers
: 3. Display the first 75 Fibonacci numbers
: 4. Display the first 125 Fibonacci numbers
: 5. Display the first 200 Fibonacci numbers
:
: hit me back soon as you can please!
: help me with a starting point
: read the material that i should have but cant get a start
: a sample program could help if
: that is not too much to ask
: i am in a bind here
:
:
Once you are familiar with those, you can start to write a function to find the n-th Fibonacci number. The easiest way to do this, is to check if n > 1 and write a loop from 2 to n which remembers the previous 2 numbers. Example:
[code]
Loop {
previous2 = previous1
previous1 = current
current = previous1 + previous2
}
[/code]
An alternative approach uses a recursive funcion:
[code]
function F(n);
if n > 2 then {
result = F(n-1)+F(n-2)
} else if n = 1 then {
result = 1
} else {
result = 0;
}
[/code]
• Posts: 15Member
You won't get further than to the 46th fibonacci number using 32-bits ints (int), the next summation causes an overflow. For about 120 numbers I can only guess that 64-bit int (long) may hold, but for anything above that you need to use the BigInt class. The numbers expand very quickly.

: : [b][red]This message was edited by jcherring4 at 2007-3-12 2:25:42[/red][/b][hr]
: : Look guys i am new to this and got myself behind on this thing can i beg for some help here please help me with this program!!!!!
: : this is what the display should look like
: :
: : 1. Display the first 25 Fibonacci numbers
: : 2. Display the first 50 Fibonacci numbers
: : 3. Display the first 75 Fibonacci numbers
: : 4. Display the first 125 Fibonacci numbers
: : 5. Display the first 200 Fibonacci numbers
: :
: : hit me back soon as you can please!
: : help me with a starting point
: : read the material that i should have but cant get a start
: : a sample program could help if
: : that is not too much to ask
: : i am in a bind here
: :
: :
: Once you are familiar with those, you can start to write a function to find the n-th Fibonacci number. The easiest way to do this, is to check if n > 1 and write a loop from 2 to n which remembers the previous 2 numbers. Example:
: [code]
: Loop {
: previous2 = previous1
: previous1 = current
: current = previous1 + previous2
: }
: [/code]
: An alternative approach uses a recursive funcion:
: [code]
: function F(n);
: if n > 2 then {
: result = F(n-1)+F(n-2)
: } else if n = 1 then {
: result = 1
: } else {
: result = 0;
: }
: [/code]
:

• Posts: 67Member