solve problem 9

This commit is contained in:
Colin McMillen 2020-11-18 18:23:26 -05:00
parent 09ddcab5a4
commit 261511f44c

View File

@ -194,8 +194,26 @@ namespace Euler {
return maxProduct;
}
[Fact]
static long Problem9() {
for (int a = 1; a <= 333; a++) {
for (int b = a + 1; b < 1000 - a; b++) {
int c = 1000 - b - a;
if (c < b) {
break;
}
if (a * a + b * b == c * c) {
int result = a * b * c;
Assert.Equal(31875000, result);
return result;
}
}
}
return 0;
}
static void Main(string[] args) {
WriteLine(Problem8());
WriteLine(Problem9());
}
}
}