PRINT SUM OF NATURAL NUMBER IN JAVA

In this code, the user is prompted to enter a positive integer. Then, a for loop is used to iterate from 1 to the given number (n). The loop adds each number to the sum variable. Finally, the result is printed to the console. Note that the code assumes the user will enter a positive… Continue reading PRINT SUM OF NATURAL NUMBER IN JAVA