The solution follows the same concept (again we need to generate all combinations for the n element). Following these steps, try to solve the problem yourself.
- Declare and initialize variable of type
intand read the input from the console.
- Nest six
forloops one in each other, for every single digit of the searched 6-digit numbers.
- In the last loop, using
ifconstruction check if the product of the six digits is equal to the magic number.