desislava_topuzakova

02. Numbers N...1

Oct 2nd, 2021
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NumbersFromNto1 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.         //отпечатвам числата от n до 1
  8.         //n = 5 -> 5 4 3 2 1
  9.         //какво повтарям? -> отпечатвам числото
  10.         //начална стойност: n
  11.         //крайна стойност: 1
  12.         //промяна: намалям стойността с 1
  13.  
  14.         for (int number = n; number >= 1; number--) {
  15.             System.out.println(number);
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment