# Program to compute the sum of the first n numbers # Matt Bishop, January 26, 2012 # for ECS 10 Winter 2012 def main(): # initialize variables total = 0 # read how high we are to count try: n = int(input("Please enter a number: ")) except: print("You need to enter a number") return # loop over the first n numbers, # adding them as we go for i in range(1,n+1): total = total + i # print out the total print("The total of the first", n, "positive numbers is", total) main()