Cody

Problem 2576. Sum of series II

Solution 1890069

Submitted on 2 Aug 2019
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
n = 1; s_correct = 1; assert(isequal(sumOfSeriesII(n),s_correct))

ans = 1

2   Fail
n = 2; s_correct = 10; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test2 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))

3   Fail
n = 3; s_correct = 35; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test3 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))

4   Fail
n = 4; s_correct = 84; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test4 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))

5   Fail
n = 5; s_correct = 165; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test5 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))

6   Fail
n = 11; s_correct = 1771; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test6 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))

7   Fail
n = 42; s_correct = 98770; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test7 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))

8   Fail
n = 71; s_correct = 477191; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test8 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))

9   Fail
n = 123; s_correct = 2481115; assert(isequal(sumOfSeriesII(n),s_correct))

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in sumOfSeriesII (line 2) sum((2*[1:n]-1)^2) Error in Test9 (line 3) assert(isequal(sumOfSeriesII(n),s_correct))