Advertisement
Spocoman

03. Lucky Numbers

Aug 30th, 2024 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LuckyNumbers {
  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 i = 1; i <= 9; i++) {
  9.             for (int k = 1; k <= 9; k++) {
  10.                 for (int j = 1; j <= 9; j++) {
  11.                     for (int x = 1; x <= 9; x++) {
  12.                         if (i + k == j + x && n % (i + k) == 0) {
  13.                             System.out.printf("%d%d%d%d ", i , k , j , x);
  14.                         }
  15.                     }
  16.                 }
  17.             }
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement