import java.util.Scanner; public class ExplorersCivics { public static long parking(int n) { // Precondition: n >= 0 // Postcondition: return the number of ways to fill n spots // with Explorers and Civics if Civics take one spot and Explorers take two spots. // Civics are indistinguishable; Explorers are indistinguishable. if (n == 0) return 1; // empty set else if (n == 1) return 1; // one civic else return parking (n-1) // civic in last position + parking (n-2); // explorer in last position } public static void main(String[] args) { // TODO Auto-generated method stub Scanner Input = new Scanner(System.in); int n; do{ System.out.println("Enter lot size n >= 0 (-1 to finish)"); n = Input.nextInt(); long[] A = new long[n+1]; if(n>=0){ System.out.println("Parking in lot size " + n + ", number of possibilities " + parking(n)); } } while (n>=0); } }