English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

pls........ help me to make this java program

2007-02-28 01:38:51 · 2 answers · asked by Rose Anne E 1 in Computers & Internet Programming & Design

2 answers

See the following reference:
http://en.wikipedia.org/wiki/Fibonacci_number

As to writing the program...

TRY IT FIRST before asking for help!

You will NEVER get it, by letting others do it for you!

You will find TONS of help here if you can't quite get it right on your own, but at least MAKE THE EFFORT and show us what you got... THEN we will be glad to assist in making it correct!

2007-02-28 01:45:06 · answer #1 · answered by N2FC 6 · 2 0

/** $Id: Fibonacci.java
* fib(0) = 0
* fib(1) = 1
* fib(n+2) = fib(n+1) + fib(n)
*/
//--------------------
public
class Fibonacci extends Sequence {
private
long x0,x1;
public
Fibonacci() {
x0 = 0;
x1 = 1;
}
public
long next() {
long res = x0;
x0 = x1;
x1 = x1 + res;
return res;
}
}

2007-02-28 01:44:34 · answer #2 · answered by Martin G. 4 · 1 0

fedest.com, questions and answers