# PURPOSE: to calculate the sum of the first (n) odd counting numbers
#
# INPUT(S): the number (n) which will be the last number added to the sum
#
# OUTPUT(S): the sum of the first (n) counting numbers
#
# EXAMPLES: input: 23 ; output: 144
# input: 15 ; output: 64
#
################################################################################
import math
def sums(n):
total = 0
for i in range(0, n + 1, 1):
total += i
return total
def main():
n = input('Enter a number: ')
s = sums(n)
print 'The sum of the numbers is', s
while n <= 0:
print "Please Enter a positive number."
break
main()
the code in this program is actually to calculate just the sum of (n) counting numbers. what i'm trying to do is listed in the purpose and i know that the "sum= 1 +3+5 +7+...+2n -1" but i've tried numerous ways to figure out how to correctly modify the above code to print the right calculations of the sum. any type of help is welcome, thanks!