Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2.  
  3. class MagicNumbers
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int magicNum = int.Parse(Console.ReadLine());
  8.  
  9.         for (int i = 111111; i < 999999; i++)
  10.         {
  11.             int currentMultiplication = 1;
  12.             int currentCombination = i;
  13.             while (currentCombination > 0)
  14.             {
  15.                 currentMultiplication *= currentCombination % 10;
  16.                 currentCombination /= 10;
  17.             }
  18.             if (currentMultiplication == magicNum)
  19.             {
  20.                 Console.Write(i + " ");
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement