Write a MATLAB function that takes a positive integer ( n ) as input and returns the sum of all the even numbers from 1 to ( n ).
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers22
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
52718 Solvers
-
Back to basics 21 - Matrix replicating
1794 Solvers
-
130 Solvers
-
Converts numbers into characters
2030 Solvers
-
110 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
峡胜, the description suggests to me that if n = 3 (as in the test), then the sum should be 2. Do you mean that we should add every other number (i.e., 1 and 3)?
I think you meant that the odd numbers (not the even ones) should be summed.