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