返回列表 發帖
  1. import java.util.Scanner;
  2. public class Ch06
  3. {
  4.             static int fai(int n)
  5.             {
  6.                     if(n<2)
  7.                             return n;
  8.                     else
  9.                             return fai(n-2)+fai(n-1);
  10.             }
  11.             public static void main(String[] args)
  12.             {
  13.                     int n;
  14.                     Scanner s=new Scanner(System.in);
  15.                     System.out.print("What is the number of times to calculate the Fischer number?" );
  16.             n=s.nextInt();
  17.             for(int i=0; i<=n; i++)
  18.             {
  19.                     System.out.print(fai(i)+" ");
  20.             }
  21.             }
  22.             
  23. }
複製代碼

TOP

返回列表