Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MagicNumbers {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int magicNumber = Integer.parseInt(scan.nextLine());
- for (int first = 1; first <= 9; first++) {
- for (int second = 1; second <= 9; second++) {
- for (int third = 1; third <= 9; third++) {
- for (int fourth = 1; fourth <= 9; fourth++) {
- for (int fifth = 1; fifth <= 9; fifth++) {
- for (int sixth = 1; sixth <= 9; sixth++) {
- int product = first * second * third * fourth * fifth * sixth;
- if(product == magicNumber){
- String number = "" + first + second + third + fourth + fifth + sixth;
- System.out.print(number + " ");
- }
- }
- }
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment