- package o;
- import java.util.Scanner;
- public class foraddfinal
- {
-
- 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.println("Please enter the amoount of times you need: ");
- n=s.nextInt();
- for(int i=0; i<=n; i++)
- {
- System.out.println(fai(i)+" ");
- }
- }
- }
複製代碼 |