Given a positive int
variable n
, write a snippet of Java code that prints the sum of the positive integers
between 1
and n
, inclusive.
For example, if n = 4
, since 1 + 2 + 3 + 4 = 10
, your code should print out 10
.
Stuck? You may find these lessons helpful: