View Code of Problem 23

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            int m=scanner.nextInt();
            if(m==0){
                break;
            }
            long s=1;
            long b=0;
            for(int i=1;i<=m;i++){
                long t=b;
                b+=s;
                s=t;
            }
            System.out.println(b+s);
        }
    }
}

Double click to view unformatted code.


Back to problem 23