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