Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- System.out.println("Number:");
- int count = keyboard.nextInt();
- int sum=0;
- for (int n = 1; n <= count; n++) {
- System.out.print(n + "\t");
- sum=sum+n;
- }
- System.out.println("\nThe sum is " + sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement