Problem 44554. The maximum sum of squares
Create a function file with an input maxval to determine the maximum number of terms for the series 1^2 + 2^2 + 3^2 + ... such that the sum is <= maxval. The function should return the number of terms. The function should return 13 when maxval=1000.
Solution Stats
Problem Comments
-
2 Comments
David Verrelli
on 14 Apr 2018
Hi, DP. You have created a nice problem here: well done. Could you please clarify/check/amend one detail though. In the Problem Statement it stipulates the sum must be that "less than" maxval. So if maxval=1, then the series would have no terms (hence sum=0); alternatively, if it had one term, then the sum (1²=1) would be "less than or equal to" maxval, as implied in the Test Suite. Thanks, DIV
David Verrelli
on 3 May 2018
Thanks for the clarification!
Solution Comments
Show commentsProblem Recent Solvers44
Suggested Problems
-
Arrange Vector in descending order
13080 Solvers
-
Getting the absolute index from a matrix
254 Solvers
-
1219 Solvers
-
829 Solvers
-
The sum of the numbers in the vector
636 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!