using System; using System.Collections.Generic; using System.Text; namespace Euler9 { class Program { //Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000. static void Main(string[] args) { //a² + b² = c² //a + b + c = 1000 for (int i = 1; i <= 1000; ++i) { for (int j = 1; j <= 1000; ++j) { double c = Math.Sqrt(Math.Pow(i, 2) + Math.Pow(j, 2)); if (Math.Round(c) == c) { if (i + j + c == 1000) { Console.WriteLine("Found: product is" + (i*j*c)); Console.ReadKey(); } } } } } } }