logo CodeStepByStep logo

sumTo

Language/Type: Java errors for loops method basics return

What is wrong with the following sumTo method, which attempts to add all numbers from 1 to a given maximum? Correct the code so that it properly implements this behavior. For example the call of sumTo(5) should return 1+2+3+4+5 = 15. You may assume that the value passed is at least 1.

Method: Write a Java method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.