Pythagorean triplet
-
Hi, don't know really where to post this but because I wrote the program in c# to solve this problem, I guess its as good a place as any. Project Euler is for bored programmers (like myself) that like to solve problems. Well I am pretty sure I solved problem 9[^] correctly, yet the site tells me i'm crazy. The answer I got was: {200, 375, 425} [a^2 + b^2 = c^2] And the product of abc is 6375000000. Am I reading the problem wrong? This checks out on my end, please double check this for me and let me know I'm not crazy.
Matthew Hazlett Fighting the good fight for web usability.
-
Hi, don't know really where to post this but because I wrote the program in c# to solve this problem, I guess its as good a place as any. Project Euler is for bored programmers (like myself) that like to solve problems. Well I am pretty sure I solved problem 9[^] correctly, yet the site tells me i'm crazy. The answer I got was: {200, 375, 425} [a^2 + b^2 = c^2] And the product of abc is 6375000000. Am I reading the problem wrong? This checks out on my end, please double check this for me and let me know I'm not crazy.
Matthew Hazlett Fighting the good fight for web usability.
Heres the code if you want to see how I did it:
int objectNum = 1000; for (int counterOne = 1; counterOne < objectNum; counterOne++) { for (int counterTwo = 1; counterTwo < objectNum; counterTwo++) { double a = Math.Pow(counterOne, 2); double b = Math.Pow(counterTwo, 2); double c = Math.Sqrt(a + b); if (Math.Truncate(c) == c) if (counterOne + counterTwo + c == (double)objectNum) Console.WriteLine("{0}, {1}, {2}", counterOne, counterTwo, c); } }
Matthew Hazlett Fighting the good fight for web usability.
-
Hi, don't know really where to post this but because I wrote the program in c# to solve this problem, I guess its as good a place as any. Project Euler is for bored programmers (like myself) that like to solve problems. Well I am pretty sure I solved problem 9[^] correctly, yet the site tells me i'm crazy. The answer I got was: {200, 375, 425} [a^2 + b^2 = c^2] And the product of abc is 6375000000. Am I reading the problem wrong? This checks out on my end, please double check this for me and let me know I'm not crazy.
Matthew Hazlett Fighting the good fight for web usability.
lol, the answer is right, I just multiplied wrong to get the product.. lol I'm an idiot. The correct answer is: 31,875,000
Matthew Hazlett Fighting the good fight for web usability.