Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.println("Inserisci un numero : ");
- int input = scan.nextInt();
- if (input != 0) {
- System.out.println("Numero di input : " + input);
- System.out.print("I primi n numeri naturali sono: ");
- int somma = 0;
- for (int x = input; x > 0; x--) {
- System.out.print(x + ",");
- somma = somma + x;
- }
- System.out.println(" ");
- System.out.print("la somma del numero naturale fino a n termini รจ : " + somma);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement