ralitsa_d

MagicNumbers

Feb 4th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MagicNumbers {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int magicNumber = Integer.parseInt(scan.nextLine());
  8.  
  9. for (int first = 1; first <= 9; first++) {
  10. for (int second = 1; second <= 9; second++) {
  11. for (int third = 1; third <= 9; third++) {
  12. for (int fourth = 1; fourth <= 9; fourth++) {
  13. for (int fifth = 1; fifth <= 9; fifth++) {
  14. for (int sixth = 1; sixth <= 9; sixth++) {
  15.  
  16. int product = first * second * third * fourth * fifth * sixth;
  17. if(product == magicNumber){
  18. String number = "" + first + second + third + fourth + fifth + sixth;
  19. System.out.print(number + " ");
  20. }
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }
Add Comment
Please, Sign In to add comment