Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MathPuzzle
- {
- class Program
- {
- static void Main()
- {
- int K = int.Parse(Console.ReadLine());
- int muster = 0;
- int multiplication = 0;
- bool nonum = false;
- for (int a = 1; a <= 30; a++)
- {
- for (int b = 1; b <= 30; b++)
- {
- for (int c = 1; c <= 30; c++)
- {
- muster = a + b + c;
- multiplication = a * b * c;
- if (muster == K)
- {
- if (a < b && b < c)
- {
- Console.WriteLine($"{a} + {b} + {c} = {muster}");
- nonum = true;
- }
- }
- else if (multiplication == K)
- {
- if (a > b && b > c)
- {
- Console.WriteLine($"{a} * {b} * {c} = {multiplication}");
- nonum = true;
- }
- }
- }
- }
- }
- if (nonum==false)
- {
- Console.WriteLine("No!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement