Skip to content
DeepForgeby svx
All problems
EasyCalculusca-348

Alternating Series Remainder Bound

Problem

For an alternating series with decreasing term magnitudes, the truncation error after using the first n terms is bounded by the magnitude of the next term.

Given the list of term magnitudes and the number of terms used, return the bound; return None when there is no next term.

Hint

The first omitted term controls the error.

Test cases

case 1
in: [[1,0.5,0.25,0.125],2]
expected: 0.25
case 2
in: [[1,0.1],0]
expected: 1
case 3
in: [[2,1],2]
expected: null
Starter codePython
def alternating_series_remainder_bound(terms, used):
    # Your code here
    pass

3 test cases · run your code against them in the editor