Q4: Write a program in python to calculate sum of first 10 natural numbers
Answers
Answered by
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
Hindi,
4 months ago
Hindi,
4 months ago
Business Studies,
9 months ago
Social Sciences,
9 months ago
English,
1 year ago