I have been recently started learning Java and would want to make code that sums the numbers from 1 to 100 (result would be 5050)
The code should go like 1+2+3+4+5+6+7+8+
Hey you can find the sum from 1 to 100 like this also. Just a option.
You can use the mathematical formula for sum of numbers i.e n(n+1)/2
public class test { public static void main(String[] args) { int i =100; int sum = (i)*(i+1)/2; System.out.println(sum); } }