Main.java 461B

12345678910111213141516171819202122232425
  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 in = new Scanner(System.in);
  8. int sum=0;
  9. System.out.println("Enter the number");
  10. int num=in.nextInt();
  11. for(int i=1; i<= num; i++)
  12. {
  13. sum= sum+ i;
  14. }
  15. System.out.println("Sum of the number is " + sum);
  16. }
  17. }