Math, asked by ankushkundu78, 9 months ago

Q4: Write a program in python to calculate sum of first 10 natural numbers

Answers

Answered by yash778919
9

The sum of the first n natural number = n * (n+1) / 2, for n a natural number.

the average of first n natural number = ( n * (n+1) / 2) / n

For example:

n = 10

sum = n * (n+1) / 2

average = ( n * (n+1) / 2) / n

print("Sum of fthe irst ", n, "natural numbers using formula is: ", sum )

print("Average of the first ", n, "natural numbers using formula is: ", average )

Similar questions