Package Algorithm.cxg.Fibonacci;
Import Java.util.Scanner; /** * Implementation of the Fibonacci pull function * Fibonacci sequence: * Starting with 0 and 1, the Faiponasi coefficients are added to the previous two numbers, and the form is as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, .... * In mathematics, it is defined in a recursive way: * f_0=0 * f_1=1 * f_n = f_{n-1}+ f_{n-2} * Implementation requirements: input of the
Ordinal n returns to get corresponds to Fibonacci that West number * @author Admin * */public class Fibonacci {public static void main (string[] args) {/*//The first two items of the definition series
int a=0,b=1;
Defines the nth item Scanner scan = new Scanner (system.in);
System.out.println ("Please enter the number of n items within 30 items of the Fibonacci series:");
int n = scan.nextint ();
Output System.out.println (the number of nth items within 30 of the Fibonacci series is: ");
System.out.print (+ "\ n" +b+ "\ n");
Based on the function of the series, the calculation for (int i = 0; I <= i++) {n=a+b;
A=b;
B=n;
System.out.println (n+ "T");
}*/System.out.println (the number of nth items within 30 of the Fibonacci series is: ");
for (int j = 1; J <= J + +) {System.out.print (Getfibonacco (j) + "T");
}///recursive function implementation sequence public static int Getfibonacco (int i) {if (i==1) {0;else if (i==1 | | i==2) {return 1;
else {return Getfibonacco (i-1) +getfibonacco (i-2); }
}
}