import java.util.Scanner; public class SumSeries { public static int sum(int no) { if (no == 1) return(1); else return(no + sum(no-1)); } public static void main(String [] args) { int last; int total; 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); } }