desislava_topuzakova

03. Numbers 1...N with Step 3

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