/** * COMP 1711 (Fall 2005) * * Solution to Challenge Problem #3 (Nth Day of Christmas) * * @author Based on a solution by Patrick DeNiverville * @version Oct-18-2005 */ public class Problem03 { public static int nthDay(int N) { int ithDayTotal = 0; int grandTotal = 0; if(N <= 0) { return -1; } // if for(int i = 1; i <= N; i++) { ithDayTotal += i; grandTotal += ithDayTotal; } // for i return grandTotal; } // nthDay(int) } // class Problem03