Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class specialNumbers {
- 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 num = i;
- boolean isSpecial = true;
- while(num>0){
- int lastDigit = num % 10;
- if(lastDigit == 0){
- isSpecial = false;
- }else if(n % lastDigit != 0){
- isSpecial = false;
- }
- num = num / 10;
- }
- if(isSpecial){
- System.out.printf("%d ",i);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment