Advertisement
Dilyana86

Untitled

May 2nd, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class specialNumbers {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int n = Integer.parseInt(scan.nextLine());
  7. for(int i=1111 ; i<=9999 ; i++){
  8. int num = i;
  9. boolean isSpecial = true;
  10. while(num>0){
  11. int lastDigit = num % 10;
  12. if(lastDigit == 0){
  13. isSpecial = false;
  14. }else if(n % lastDigit != 0){
  15. isSpecial = false;
  16. }
  17. num = num / 10;
  18. }
  19. if(isSpecial){
  20. System.out.printf("%d ",i);
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement