Advertisement
Lyutov02

StopNumber

Dec 3rd, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class StopNumber {
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner sc = new Scanner(System.in);
  8.  
  9.         System.out.print("Enter your first number: ");
  10.         int N = Integer.parseInt(sc.nextLine());
  11.         System.out.print("Enter your second number: ");
  12.         int M = Integer.parseInt(sc.nextLine());
  13.         System.out.print("Enter your stop number: ");
  14.         int S = Integer.parseInt(sc.nextLine());
  15.  
  16.         for (int i = M; i >= N; i--) {
  17.             if (i % 2 == 0 && i % 3 == 0) {
  18.                 if (i == S) {
  19.                     break;
  20.                 }
  21.                 System.out.print(i + " ");
  22.             }
  23.         }
  24.  
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement