import java.util.Scanner; /* Author: James Tam Version: 2015 Learning objectives: tracing a simple recursive example that sums a series of numbers. */ public class SumSeries { static int sum(int no) { if (no == 1) return(1); else return(no + sum(no-1)); } public static void main(String args []) { int last = -1; int total = -1; Scanner in = new Scanner(System.in); System.out.print("Enter the last number: "); last = in.nextInt(); total = sum(last); System.out.println("The sum of the series from " + "1 to " + last + " is " + total); } }