Answers for "calculating the sum of all numbers from 1 to a given number by user python"

1

program to find sum till n natural numbers in python

#sum of natural number till n.
n=int(input('no. :'))
gross=0
no=0
while no < n:
    no+=1
    gross+=no
    print('no.', no ,'sum of n', gross)
print('no.',n,'total',gross)
Posted by: Guest on December-11-2021
0

Accept number from user and calculate the sum of all number from 1 to a given number

n = int(input("Enter number"))
sum = 0
for num in range(1, n + 1, 1):
    sum = sum + num
print("Sum of numbers is: ", sum)
Posted by: Guest on June-03-2021

Code answers related to "calculating the sum of all numbers from 1 to a given number by user python"

Python Answers by Framework

Browse Popular Code Answers by Language