- import java.util.Scanner;
- public class Ch06
- {
- static int fai(int n)
- {
- if(n<2)
- return n;
- else
- return fai(n-2)+fai(n-1);
- }
- public static void main(String[] args)
- {
- int n;
- Scanner s=new Scanner(System.in);
- System.out.print("What is the number of times to calculate the Fischer number?" );
- n=s.nextInt();
- for(int i=0; i<=n; i++)
- {
- System.out.print(fai(i)+" ");
- }
- }
-
- }
複製代碼 |