Advertisement
Niicksana

Magic numbers

Dec 3rd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Magic_numbers
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.          // Variant 1
  14.             int n = int.Parse(Console.ReadLine());
  15.  
  16.             int n1 = 0;
  17.             int n2;
  18.             int n3;
  19.             int n4;
  20.             int n5;
  21.             int n6;
  22.  
  23.             while (n1 <= 9)
  24.             {
  25.                 n2 = 0;
  26.                 while (n2 <= 9)
  27.                 {
  28.                     n3 = 0;
  29.                     while (n3 <= 9)
  30.                     {
  31.                         n4 = 0;
  32.                         while (n4 <= 9)
  33.                         {
  34.                             n5 = 0;
  35.                             while (n5 <= 9)
  36.                             {
  37.                                 n6 = 0;
  38.                                 while (n6 <= 9)
  39.                                 {
  40.                                     if (n1 * n2 * n3 * n4 * n5 * n6 == n)
  41.                                     {
  42.                                         Console.Write("{0}{1}{2}{3}{4}{5}", n1, n2, n3, n4, n5, n6);
  43.                                         Console.Write(" ");
  44.                                     }
  45.                                     n6++;
  46.                                 }
  47.                                 n5++;
  48.                             }
  49.                             n4++;
  50.                         }
  51.                         n3++;
  52.                     }
  53.                     n2++;
  54.                 }
  55.                 n1++;
  56.             }
  57.             Console.WriteLine();
  58.  
  59.         //  Variant 2
  60.  
  61.           /*int magic = int.Parse(Console.ReadLine());
  62.  
  63.             for (int num1 = 0; num1 <= 9; num1++)
  64.             {
  65.                 for (int num2 = 0; num2 <= 9; num2++)
  66.                 {
  67.                     for (int num3 = 0; num3 <= 9; num3++)
  68.                     {
  69.                         for (int num4 = 0; num4 <= 9; num4++)
  70.                         {
  71.                             for (int num5 = 0; num5 <= 9; num5++)
  72.                             {
  73.                                 for (int num6 = 0; num6 <= 9; num6++)
  74.                                 {
  75.                                     if (num1 * num2 * num3 * num4 * num5 * num6 == magic)
  76.                                     {
  77.                                         Console.Write("{0}{1}{2}{3}{4}{5}", num1, num2, num3, num4, num5, num6);
  78.                                         Console.Write(" ");
  79.                                     }
  80.                                 }
  81.                             }
  82.                         }
  83.                     }
  84.                 }
  85.             }
  86.             Console.WriteLine();*/
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement