Cody

# Problem 2801. geometric progression

Solution 551044

Submitted on 31 Dec 2014 by Guillaume
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
%% test 1 nterms = 10; term0 = randi(10) ratio = (-1)^randi(2)*randi(10) correctsequence = term0*ratio.^(0:nterms-1); for position = 1:nterms errorsequence = correctsequence; errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50); [errorposition, truesequence] = find_error(errorsequence); assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 1 at position %d', position); end

term0 = 7 ratio = 7

2   Pass
%%test 2, fractional ratio nterms = 15; term0 = randi(10) ratio = (-1)^randi(2)*randi(10) correctsequence = term0*ratio.^(0:nterms-1); for position = 1:nterms errorsequence = correctsequence; errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50); [errorposition, truesequence] = find_error(errorsequence); assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 2 at position %d', position); end

term0 = 9 ratio = 3