// Helene Martin, Garfield High School
// Demonstrates use of cumulative sum pattern

import java.util.*;

public class CumulativeSum {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		System.out.print("Numbers to add? ");
		int count = in.nextInt();
		
		int total = 0; // must be initialized here or out of scope
		
		for(int i = 1; i <= count; i++) {
			total += i; // equivalent to total = total + i
		}
		
		System.out.println("Sum of numbers between 1 and " + count + ": " + total);
	}
}
