Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Task15 {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. System.out.print("Please enter n: ");
  8. int n = sc.nextInt();
  9. int sum = 0;
  10. int i = 1;
  11. do {
  12. sum += i;
  13. i++;
  14. }while(i <= n);
  15. System.out.println("sum = " + sum);
  16. }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement