Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Program {
  3. public static void main(String[] args) {
  4. Scanner scNumb =new Scanner(System.in);
  5. int numb = scNumb.nextInt();
  6. int sum = 0;
  7. for(int i=1;i<=numb;i++){
  8. sum +=i;
  9. System.out.println(sum);
  10. }
  11. }
  12. }
  13.  
  14. 1
  15. 3
  16. 6
  17. 10
  18. 15
  19.  
  20. 1+0=1
  21. 1+2=3
  22. 3+3=6
  23. 6+4=10
  24. 10+5=15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement