Topic: Recursion
Using recursion, write a program that returns the sum of the following series.
_
#Challenge
Answers
Answered by
17
Hint:
For this series:
The Code:
The problem is solved using Python.
f=lambda x: (x*(x-1))**2//2 # defines f(x)
sum=lambda n:f(n)+sum(n-1) if n else 0 # defines sum(n)
n=int(input('Enter limit: ')) # accepts limit.
print(f'Sum of first {n} terms of the series is {sum(n)}.') # displays sum.
Algorithm:
The sum can be calculated using the following recursive algorithm.
Where f(n) denotes the nᵗʰ term of the series, given by:
See attachment for output.
Attachments:
anindyaadhikari13:
Thanks for the brainliest :)
Similar questions