Cody

Problem 44860. Sum of a geometric series

Solution 2043766

Submitted on 3 Dec 2019 by Mathworlds
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
a = 1; r= 0.1; n=10; y_correct = a*(1 - r^n)/(1-r); assert(isequal(your_fcn_name(a,r,n),y_correct))

ans = 1.1111

2   Pass
a = 0.2; r= 0.2; n=5; y_correct = a*(1 - r^n)/(1-r); assert(isequal(your_fcn_name(a,r,n),y_correct))

ans = 0.2499

3   Pass
a = 0.4; r= 0.3; n=7; y_correct = a*(1 - r^n)/(1-r); assert(isequal(your_fcn_name(a,r,n),y_correct))

ans = 0.5713

Suggested Problems

More from this Author10

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!