Cody

Problem 3. Find the sum of all the numbers of the input vector

Solution 952097

Submitted on 1 Sep 2016 by Lorenzo Valentini
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 = 1; y_correct = 1; assert(isequal(vecsum(x),y_correct))

y = 1 y = 1

2   Pass
x = [1 2 3 5]; y_correct = 11; assert(isequal(vecsum(x),y_correct))

y = 1 3 6 11 y = 11

3   Pass
x = [1 2 3 5]; y_correct = 11; assert(isequal(vecsum(x),y_correct))

y = 1 3 6 11 y = 11

4   Pass
x = 1:100; y_correct = 5050; assert(isequal(vecsum(x),y_correct))

y = Columns 1 through 8 1 3 6 10 15 21 28 36 Columns 9 through 16 45 55 66 78 91 105 120 136 Columns 17 through 24 153 171 190 210 231 253 276 300 Columns 25 through 32 325 351 378 406 435 465 496 528 Columns 33 through 40 561 595 630 666 703 741 780 820 Columns 41 through 48 861 903 946 990 1035 1081 1128 1176 Columns 49 through 56 1225 1275 1326 1378 1431 1485 1540 1596 Columns 57 through 64 1653 1711 1770 1830 1891 1953 2016 2080 Columns 65 through 72 2145 2211 2278 2346 2415 2485 2556 2628 Columns 73 through 80 2701 2775 2850 2926 3003 3081 3160 3240 Columns 81 through 88 3321 3403 3486 3570 3655 3741 3828 3916 Columns 89 through 96 4005 4095 4186 4278 4371 4465 4560 4656 Columns 97 through 100 4753 4851 4950 5050 y = 5050

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!