# Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +...
def series_sum(n):
result = 0.0
for i in range(n):
result += 1/(3*i+1)
return format(result,'.2f')
print(series_sum(1))
print(series_sum(2))
print(series_sum(3))
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.