Main.java 423B

123456789101112131415161718192021
  1. /**
  2. * Created by iyasuwatts on 10/17/17.
  3. */
  4. import java.util.*;
  5. public class Main {
  6. public static void main(String[] args){
  7. Scanner input=new Scanner(System.in);
  8. System.out.println("Enter the limit");
  9. int n=input.nextInt();
  10. int sum=0;
  11. for(int i=1;i<=n;i++)
  12. {
  13. sum=sum+i;
  14. }
  15. System.out.printf("\nThe sum is %d",sum);
  16. }
  17. }