Cody

# Problem 2576. Sum of series II

Solution 2815783

Submitted on 10 Aug 2020 by Joshua Burke
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))

s = 1 s = 1

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

s = 1 s = 1 9 s = 10

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

s = 1 s = 1 9 s = 1 9 25 s = 35

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

s = 1 s = 1 9 s = 1 9 25 s = 1 9 25 49 s = 84

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

s = 1 s = 1 9 s = 1 9 25 s = 1 9 25 49 s = 1 9 25 49 81 s = 165

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

s = 1 s = 1 9 s = 1 9 25 s = 1 9 25 49 s = 1 9 25 49 81 s = 1 9 25 49 81 121 s = 1 9 25 49 81 121 169 s = 1 9 25 49 81 121 169 225 s = 1 9 25 49 81 121 169 225 289 s = 1 9 25 49 81 121 169 225 289 361 s = 1 9 25 49 81 121 169 225 289 361 441 s = 1771

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

s = 1 s = 1 9 s = 1 9 25 s = 1 9 25 49 s = 1 9 25 49 81 s = 1 9 25 49 81 121 s = 1 9 25 49 81 121 169 s = 1 9 25 49 81 121 169 225 s = 1 9 25 49 81 121 169 225 289 s = 1 9 25 49 81 121 169 225 289 361 s = 1 9 25 49 81 121 169 225 289 361 441 s = 1 9 25 49 81 121 169 225 289 361 441 529 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 961 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 17 961 1089 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 18 961 1089 1225 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 19 961 1089 1225 1369 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 20 961 1089 1225 1369 1521 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 21 961 1089 1225 1369 1521 1681 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 22 961 1089 1225 1369 1521 1681 1849 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 23 961 1089 1225 1369 1521 1681 1849 2025 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 24 961 1089 1225 1369 1521 1681 1849 2025 2209 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 25 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 26 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 27 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 28 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 29 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Column 31 3721 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 32 3721 3969 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 33 3721 3969 4225 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 34 3721 3969 4225 4489 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 35 3721 3969 4225 4489 4761 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 36 3721 3969 4225 4489 4761 5041 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 37 3721 3969 4225 4489 4761 5041 5329 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 38 3721 3969 4225 4489 4761 5041 5329 5625 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 15...

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

s = 1 s = 1 9 s = 1 9 25 s = 1 9 25 49 s = 1 9 25 49 81 s = 1 9 25 49 81 121 s = 1 9 25 49 81 121 169 s = 1 9 25 49 81 121 169 225 s = 1 9 25 49 81 121 169 225 289 s = 1 9 25 49 81 121 169 225 289 361 s = 1 9 25 49 81 121 169 225 289 361 441 s = 1 9 25 49 81 121 169 225 289 361 441 529 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 961 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 17 961 1089 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 18 961 1089 1225 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 19 961 1089 1225 1369 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 20 961 1089 1225 1369 1521 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 21 961 1089 1225 1369 1521 1681 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 22 961 1089 1225 1369 1521 1681 1849 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 23 961 1089 1225 1369 1521 1681 1849 2025 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 24 961 1089 1225 1369 1521 1681 1849 2025 2209 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 25 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 26 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 27 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 28 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 29 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Column 31 3721 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 32 3721 3969 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 33 3721 3969 4225 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 34 3721 3969 4225 4489 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 35 3721 3969 4225 4489 4761 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 36 3721 3969 4225 4489 4761 5041 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 37 3721 3969 4225 4489 4761 5041 5329 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 38 3721 3969 4225 4489 4761 5041 5329 5625 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 15...

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

s = 1 s = 1 9 s = 1 9 25 s = 1 9 25 49 s = 1 9 25 49 81 s = 1 9 25 49 81 121 s = 1 9 25 49 81 121 169 s = 1 9 25 49 81 121 169 225 s = 1 9 25 49 81 121 169 225 289 s = 1 9 25 49 81 121 169 225 289 361 s = 1 9 25 49 81 121 169 225 289 361 441 s = 1 9 25 49 81 121 169 225 289 361 441 529 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 s = 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 961 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 17 961 1089 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 18 961 1089 1225 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 19 961 1089 1225 1369 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 20 961 1089 1225 1369 1521 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 21 961 1089 1225 1369 1521 1681 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 22 961 1089 1225 1369 1521 1681 1849 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 23 961 1089 1225 1369 1521 1681 1849 2025 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 24 961 1089 1225 1369 1521 1681 1849 2025 2209 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 25 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 26 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 27 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 28 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 29 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Column 31 3721 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 32 3721 3969 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 33 3721 3969 4225 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 34 3721 3969 4225 4489 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 35 3721 3969 4225 4489 4761 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 36 3721 3969 4225 4489 4761 5041 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 37 3721 3969 4225 4489 4761 5041 5329 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 1521 1681 1849 2025 2209 2401 2601 2809 3025 3249 3481 Columns 31 through 38 3721 3969 4225 4489 4761 5041 5329 5625 s = Columns 1 through 15 1 9 25 49 81 121 169 225 289 361 441 529 625 729 841 Columns 16 through 30 961 1089 1225 1369 15...

### Community Treasure Hunt

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

Start Hunting!