Created
March 8, 2017 11:45
-
-
Save LasterOfDesaster/81b6341024fdf0225cd2284e8b43f6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
for (int s = 0; s <= 9; s++) | |
{ | |
for (int p = 0; p <=9; p++) | |
{ | |
for (int d = 0; d <= 9; d++) | |
{ | |
int left = GetDecimal(s, p, d); | |
int right = Calculate(s, p, d); | |
if (left == right) | |
Console.WriteLine("{0} = ({1} + {2} + {3}) x {4} x {5} x {6}", left, s, p, d, s, p, d); | |
} | |
} | |
} | |
Console.ReadKey(); | |
} | |
static int Calculate(int s, int p, int d) | |
{ | |
return (s + p + d) * s * p * d; | |
} | |
static int GetDecimal(int s, int p, int d) | |
{ | |
string dec = string.Format("{0}{1}{2}", s, p, d); | |
int value = Convert.ToInt32(dec); | |
return value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment