Cody

Problem 2578. Sum of series IV

Solution 3199101

Submitted on 13 Oct 2020 by ivan fernandez
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(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 s = 1

2   Pass
n = 2; s_correct = -8; assert(isequal(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 sum = -8 s = -8

3   Pass
n = 3; s_correct = 17; assert(isequal(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 sum = -8 sum = 17 s = 17

4   Pass
n = 4; s_correct = -32; assert(isequal(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 sum = -8 sum = 17 sum = -32 s = -32

5   Pass
n = 7; s_correct = 97; assert(isequal(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 sum = -8 sum = 17 sum = -32 sum = 49 sum = -72 sum = 97 s = 97

6   Pass
n = 12; s_correct = -288; assert(isequal(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 sum = -8 sum = 17 sum = -32 sum = 49 sum = -72 sum = 97 sum = -128 sum = 161 sum = -200 sum = 241 sum = -288 s = -288

7   Pass
n = 33; s_correct = 2177; assert(isequal(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 sum = -8 sum = 17 sum = -32 sum = 49 sum = -72 sum = 97 sum = -128 sum = 161 sum = -200 sum = 241 sum = -288 sum = 337 sum = -392 sum = 449 sum = -512 sum = 577 sum = -648 sum = 721 sum = -800 sum = 881 sum = -968 sum = 1057 sum = -1152 sum = 1249 sum = -1352 sum = 1457 sum = -1568 sum = 1681 sum = -1800 sum = 1921 sum = -2048 sum = 2177 s = 2177

8   Pass
n = 59; s_correct = 6961; assert(isequal(sumOfSeriesIV(n),s_correct))

sum = 0 sum = 1 sum = -8 sum = 17 sum = -32 sum = 49 sum = -72 sum = 97 sum = -128 sum = 161 sum = -200 sum = 241 sum = -288 sum = 337 sum = -392 sum = 449 sum = -512 sum = 577 sum = -648 sum = 721 sum = -800 sum = 881 sum = -968 sum = 1057 sum = -1152 sum = 1249 sum = -1352 sum = 1457 sum = -1568 sum = 1681 sum = -1800 sum = 1921 sum = -2048 sum = 2177 sum = -2312 sum = 2449 sum = -2592 sum = 2737 sum = -2888 sum = 3041 sum = -3200 sum = 3361 sum = -3528 sum = 3697 sum = -3872 sum = 4049 sum = -4232 sum = 4417 sum = -4608 sum = 4801 sum = -5000 sum = 5201 sum = -5408 sum = 5617 sum = -5832 sum = 6049 sum = -6272 sum = 6497 sum = -6728 sum = 6961 s = 6961

Suggested Problems

More from this Author9

Community Treasure Hunt

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

Start Hunting!