Python @ DjangoSpin

PyPro #42 Calculate Sum of Series 1/2, 2/3, 3/4,...

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Sum of Series in Python

Sum of Series in Python

Write a Python Program to calculate sum of series 1/2, 2/3, 3/4,... upto 10 terms.

Calculate Sum of Series 1/2, 2/3, 3/4

numberOfTerms = 10
summation = 0

for nthTerm in range(1, numberOfTerms + 1):
    summation += float(float(nthTerm) / (nthTerm + 1))

print( round(summation, 2) )		# 7.98

See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply