Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MagicNumbers
- {
- using System;
- using System.Linq;
- class Program
- {
- static int[] array;
- static int n;
- static void Main(string[] args)
- {
- array = new int[6];
- n = int.Parse(Console.ReadLine());
- FindAll(0);
- }
- private static void FindAll(int index)
- {
- if (index == array.Length)
- {
- int result = MultiplyElements();
- if (result == n)
- {
- Console.Write(string.Join(string.Empty, array) + " ");
- }
- return;
- }
- for (int i = 1; i <= 9; i++)
- {
- array[index] = i;
- FindAll(index + 1);
- }
- }
- private static int MultiplyElements()
- {
- int res = 1;
- for (int i = 0; i < array.Length; i++)
- {
- res *= array[i];
- }
- return res;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement