Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Task15 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Please enter n: ");
- int n = sc.nextInt();
- int sum = 0;
- int i = 1;
- do {
- sum += i;
- i++;
- }while(i <= n);
- System.out.println("sum = " + sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement