Cody

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

Solution 1876606

Submitted on 17 Jul 2019 by Jun Baek
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))

sum = 0 sum = 1 y = 1

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

sum = 0 sum = 1 sum = 3 sum = 6 sum = 11 y = 11

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

sum = 0 sum = 1 sum = 3 sum = 6 sum = 11 y = 11

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

sum = 0 sum = 1 sum = 3 sum = 6 sum = 10 sum = 15 sum = 21 sum = 28 sum = 36 sum = 45 sum = 55 sum = 66 sum = 78 sum = 91 sum = 105 sum = 120 sum = 136 sum = 153 sum = 171 sum = 190 sum = 210 sum = 231 sum = 253 sum = 276 sum = 300 sum = 325 sum = 351 sum = 378 sum = 406 sum = 435 sum = 465 sum = 496 sum = 528 sum = 561 sum = 595 sum = 630 sum = 666 sum = 703 sum = 741 sum = 780 sum = 820 sum = 861 sum = 903 sum = 946 sum = 990 sum = 1035 sum = 1081 sum = 1128 sum = 1176 sum = 1225 sum = 1275 sum = 1326 sum = 1378 sum = 1431 sum = 1485 sum = 1540 sum = 1596 sum = 1653 sum = 1711 sum = 1770 sum = 1830 sum = 1891 sum = 1953 sum = 2016 sum = 2080 sum = 2145 sum = 2211 sum = 2278 sum = 2346 sum = 2415 sum = 2485 sum = 2556 sum = 2628 sum = 2701 sum = 2775 sum = 2850 sum = 2926 sum = 3003 sum = 3081 sum = 3160 sum = 3240 sum = 3321 sum = 3403 sum = 3486 sum = 3570 sum = 3655 sum = 3741 sum = 3828 sum = 3916 sum = 4005 sum = 4095 sum = 4186 sum = 4278 sum = 4371 sum = 4465 sum = 4560 sum = 4656 sum = 4753 sum = 4851 sum = 4950 sum = 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!