Fibonacci Fibonacci columns
A small after-school arithmetic operations, to implement is not difficult to understand, look to their own records, they come directly.
Fibonacci number (Fibonacci sequence), also known as golden columns, because mathematician Leonardo Fibonacci (Leonardoda Fibonacci) as an example to the rabbit breeding and the introduction, it is also known as "Rabbit series," referring to such a series is: 1,1,2,3,5,8,13,21,34, etc. mathematically, Fibonacci numbers are listed in the following recursive method to define: F (1) = 1, F (2) = 1, F (n) = F (n - 1) + F (n - 2) (n ≥ 3, n ∈ N *) in the fields of modern physics, quasi-crystalline structure, chemistry, Fei Bona of number have a direct application.
Directly on the bar code, the scope of the problem is not considered here, blasting int her. Large burst of data words may be int, another recursion is convenient, but may explode stack .
public static int fibonacci(int n) {
if (n < 0)
return -1;
else if (n == 0)
return 0;
else if (n == 1)
return 1;
else
return fibonacci(n - 1) + fibonacci(n - 2);
}
If you help to make a key triple! ! (Like a point may ah)