Advertisement
Spocoman

05. Special Numbers

Aug 30th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SpecialNumbers {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.  
  8.         for (int n1 = 1; n1 <= 9; n1++) {
  9.             for (int n2 = 1; n2 <= 9; n2++) {
  10.                 for (int n3 = 1; n3 <= 9; n3++) {
  11.                     for (int n4 = 1; n4 <= 9; n4++) {
  12.                         if (n % n1 == 0 && n % n2 == 0 && n % n3 == 0 && n % n4 == 0) {
  13.                             System.out.printf("%d%d%d%d ", n1, n2, n3, n4);
  14.                         }
  15.                     }
  16.                 }
  17.             }
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement