Cody

Problem 44334. Sums of Multiple Pairs of Triangular Numbers

Solution 1302473

Submitted on 19 Oct 2017 by Andrew Dobrovolc
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
x = 21; y_correct = [6;15]; assert(isequal(multi_triangular(x),y_correct))

2   Pass
x=81; y_correct=[ 3 15 36 ; 78 66 45]; assert(isequal(multi_triangular(x),y_correct))

3   Pass
x=20; y_correct=[ 10 10]; assert(isequal(multi_triangular(x),y_correct'))

[Warning: Integer operands are required for colon operator when used as index]

4   Pass
x=17956; y_correct=[ 1 190 378 1485 2556 4095 4753 6328 8911; 17955 17766 17578 16471 15400 13861 13203 11628 9045]; assert(isequal(multi_triangular(x),y_correct))

5   Pass
x=70; y_correct=[15 55]; assert(isequal(multi_triangular(x),y_correct'));

6   Pass
x=37052031; y_correct=[7503 16110 93528 119316 136503 393828 496506 778128 1033203 1194285 1675365 1876953 2503203 2627778 3214380 3436131 3983253 4226778 4943940 5112003 5279625 6063903 6417153 7055646 7771653 8456328 8855736 9801378 10015050 11221953 11580078 12834711 13846953 14084778 15149760 15387378 15531951 17096628 17567628 18395145; 37044528 37035921 36958503 36932715 36915528 36658203 36555525 36273903 36018828 35857746 35376666 35175078 34548828 34424253 33837651 33615900 33068778 32825253 32108091 31940028 31772406 30988128 30634878 29996385 29280378 28595703 28196295 27250653 27036981 25830078 25471953 24217320 23205078 22967253 21902271 21664653 21520080 19955403 19484403 18656886]; assert(isequal(multi_triangular(x),y_correct));

Suggested Problems

More from this Author80

Community Treasure Hunt

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

Start Hunting!