View Code of Problem 23

import java.util.Scanner;
 
public class Main {
	int a[]=new int [90];
	void fuzhi(){
		a[0]=1;
		a[1]=2;
		int n=2;
		while(n<90){
			a[n]=a[n-1]+a[n-2];
			n++;
		}
	}
	
 
	void get(){
		int b[]=new int[90];
		int i=0;
		Scanner scan=new Scanner(System.in);
                int n=scan.nextInt();
		while(n!=0){
			int m=n-1;
			System.out.println(a[m]);
			n=scan.nextInt();
		}
		
	}
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main r=new Main();
		r.fuzhi();
		r.get();
 
	}
 
}

Double click to view unformatted code.


Back to problem 23