Advertisement
Spocoman

Gifts from Santa

Sep 7th, 2024
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine()),
  7.                 m = Integer.parseInt(scanner.nextLine()),
  8.                 s = Integer.parseInt(scanner.nextLine());
  9.  
  10.         for (int i = m; i >= n; i--) {
  11.             if (i == s && s % 2 == 0 && s % 3 == 0) {
  12.                 break;
  13.             } else if (i % 2 == 0 && i % 3 == 0) {
  14.                 System.out.print(i + " ");
  15.             }
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement