View Code of Problem 60

import java.util.*;
public class Main {
	public static void main(String[] args)
	{
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	for (int i = 0; i < n; i++) {
		int m = sc.nextInt();
		int a1 = 2;
		int a2 = 3;
		int result = 0;
		if (m == 1) {
			result = 2;
		}
		else if (m==2) {
			result = 3;
		}
		else {
			for (int j = 3; j <= m; j++) {
				result = a1+a2;
				a1 = a2;
				a2 = result;
			}
		}
		System.out.printf("Scenario #%d:\n",i+1);
		System.out.println(result);
		System.out.println();
	}
	}
}

Double click to view unformatted code.


Back to problem 60