# Using the while loop find sum of the first 50 natural numbers (python language)?

### 2 Answers

Relevance

- frombrumLv 71 month ago
there is a better way of adding a list of consecutive numbers by rule

((n1+n2/)2)*m

where n1 is the first number n2 is the last and and m is the number of numbers

((1+50)/2)*50=1275

teach your teacher this as a better and more flexible method

otherwise - do your onw homework

- brilliant_movesLv 71 month ago
Hi, Katherine Gaguancela.

I'm using the number 1 as the starting point for the 50 natural numbers. Depends on how one defines a natural number (see link).

I've used the variable name "total" rather than "sum", which is a reserved word.

n, total = 1, 0

while (n<=50):

total += n

n += 1

print ("Sum of first 50 natural numbers is", total)

Still have questions? Get your answers by asking now.