From 261511f44c5f2c87083bc15b6c5c2e82305b3684 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 18 Nov 2020 18:23:26 -0500 Subject: [PATCH] solve problem 9 --- Program.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index 1c6a726..65f1064 100644 --- a/Program.cs +++ b/Program.cs @@ -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()); } } }