Answers for "code example of sum of the first n odd numbers using for loop"

0

code example of sum of the first n odd numbers using for loop

def OddSummation(n):
    total = 0
    for i in range(1,n,2):
        total+=i
    return total
    
    
def main():
    number = int(input("Enter the number: "))
    print("The summation of all the odd numbers between 1 and ",number, " is ",         OddSummation(number))
    
main()
Posted by: Guest on April-10-2022

Code answers related to "code example of sum of the first n odd numbers using for loop"

Python Answers by Framework

Browse Popular Code Answers by Language