Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- for (int i = 1111; i <= 9999; i++) {
- int currentNumber = i;
- boolean isSpecialNumber = true;
- while (currentNumber > 0) {
- int lastDigit = currentNumber % 10;
- currentNumber = currentNumber / 10;
- if (lastDigit != 0 && n % lastDigit != 0) {
- isSpecialNumber = false;
- break;
- }
- if (lastDigit == 0) {
- isSpecialNumber = false;
- break;
- }
- }
- if (isSpecialNumber) {
- System.out.printf("%d ", i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment