Advertisement
Guest User

MathPuzzle

a guest
Feb 29th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Fishland
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. var input = int.Parse(Console.ReadLine());
  10.  
  11. var cnt = 0;
  12.  
  13. for (int i = 1; i <= 30; i++)
  14. {
  15. for (int g = 1; g <= 30; g++)
  16. {
  17. for (int j = 1; j <= 30; j++)
  18. {
  19. if (j + g + i == input && i < g && g < j)
  20. {
  21. cnt++;
  22. Console.WriteLine($"{i} + {g} + {j} = {input}");
  23. }
  24. else if (j * g * i == input && i > g && g > j)
  25. {
  26. cnt++;
  27. Console.WriteLine($"{i} * {g} * {j} = {input}");
  28. }
  29. }
  30. }
  31. }
  32.  
  33. if (cnt == 0)
  34. {
  35. Console.WriteLine("No!");
  36. }
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement