DyNaMiXx7

Untitled

Oct 24th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int magicNumber = int.Parse(Console.ReadLine());
  8.         int sum = 0;
  9.  
  10.         for (int firstDigit = 1; firstDigit <= magicNumber; firstDigit++)
  11.         {
  12.             for (int secondDigit = 1; secondDigit <= magicNumber; secondDigit++)
  13.             {
  14.                 for (int thirdDigit = 1; thirdDigit <= magicNumber; thirdDigit++)
  15.                 {
  16.                     for (int fourthDigit = 1; fourthDigit <= magicNumber; fourthDigit++)
  17.                     {
  18.                         for (int fifthDigit = 1; fifthDigit <= magicNumber; fifthDigit++)
  19.                         {
  20.                             for (int sixthDigit = 1; sixthDigit <= magicNumber; sixthDigit++)
  21.                             {
  22.                                 sum = firstDigit * secondDigit * thirdDigit * fourthDigit * fifthDigit * sixthDigit;
  23.                                 if (sum == magicNumber)
  24.                                 {
  25.                                     Console.Write($"{firstDigit}{secondDigit}{thirdDigit}{fourthDigit}{fifthDigit}{sixthDigit} ");
  26.                                 }
  27.                             }
  28.                         }
  29.                     }
  30.                 }
  31.             }
  32.         }
  33.         Console.WriteLine();
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment