X1267: For Loop Practice

The method skeleton below takes in an integer variable top.
Using a for loop, write a method that will return the sum of all numbers from 1 to top.

For example, if top was set to 3, this method would return 6 or (1 + 2 + 3).

You can assume top will always be at least 0.

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.