Question: Recursive functions Please write the function in python and also please include explantations for each line of code in the function and a screenshot to
Recursive functions Please write the function in python and also please include explantations for each line of code in the function and a screenshot to see the correct indentation.
Define a function called sum(n) that accepts an integer number n and returns the sum of the first n terms of the geometric series, which is defined as:
Recursive therefore no loops
You can assume that n is an integer where n >= 1.
For example:
| Test | Result |
|---|---|
print("{:.3f}".format(sum(5))) | 0.969 |
print("{:.3f}".format(sum(1))) | 0.500 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
