public class Fibonacci
extends java.lang.Object
The first two terms of the Fibonacci sequence are both 1, and each subsequent term is the sum of the previous two terms.
| Constructor and Description |
|---|
Fibonacci() |
| Modifier and Type | Method and Description |
|---|---|
int |
getFibTerm(int n)
Calculates the desired term in the Fibonacci sequence.
|
public int getFibTerm(int n)
n - the index of the desired term; the first index of the sequence is 0java.lang.IllegalArgumentException - if n is negative