Advertisement
tchenkov

L07u16_MagicNumbers

Feb 21st, 2017
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 21.02.2017 г..
  7.  */
  8. public class u16_MagicNumbers {// doMagic :)
  9.     public static void main(String[] args) {
  10.         Scanner scan = new Scanner(System.in);
  11.         int magicNumber = Integer.parseInt(scan.nextLine());
  12.    
  13.         for (int i = 111111; i < 1000000; i++) {
  14.             int currentIndex = i;
  15.             int result = 1;
  16.             while (currentIndex > 0){
  17.                 result *= currentIndex % 10;
  18.                 currentIndex /= 10;
  19.             }
  20.             if (result == magicNumber) {
  21.                 System.out.printf("%d ", i);
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement