desislava_topuzakova

06. Magic NUmbers

Nov 28th, 2020
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.MagicNumbers
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int magicNumber = int.Parse(Console.ReadLine());
  10.  
  11. //111111 до 999999
  12. for (int stohil = 1; stohil <= 9; stohil++)
  13. {
  14. for (int desetohil = 1; desetohil <= 9; desetohil++)
  15. {
  16. for (int hil = 1; hil <= 9; hil++)
  17. {
  18. for (int stot = 1; stot <= 9; stot++)
  19. {
  20. for (int des = 1; des <= 9; des++)
  21. {
  22. for (int ed = 1; ed <= 9; ed++)
  23. {
  24. //генерирано число
  25. //ако ст * десхил * хил * стот * дес* ед == маг
  26. if (stohil * desetohil * hil * stot * des * ed == magicNumber)
  27. {
  28. Console.Write($"{stohil}{desetohil}{hil}{stot}{des}{ed} ");
  29. }
  30. }
  31. }
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment