Problem 60526. 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 ).
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
-
1 Comment
ChrisR
on 14 Jun 2024
峡胜, 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)?
Solution Comments
Show commentsProblem Recent Solvers15
Suggested Problems
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
1746 Solvers
-
Determine the number of odd integers in a vector
709 Solvers
-
8698 Solvers
-
Write a code that will follow the equation y = x * (x + x) * x.
327 Solvers
-
Calculate the square of a number (Super Easy)
176 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!