Inf1 OP : Lab Sheet Week 3 Q2 - While loop example - arithmetic series
Overview

Write a program called ArithmeticSeries that takes an integer \( N \) from the command-line and calculates the sum \( k \) of all numbers \( i \) such that \( 1 \leq i \leq N \). That is,

\[ k = 1 + 2 + 3 + 4 + ... + N \]

Note

Use a while loop and a loop counter to do this. All numbers should be integers.

An example of executing this program would be the following:

: java ArithmeticSeries 5
15

An automated test has been created for this exercise: ArithmeticSeriesTest.java.