A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.
static void Main(string[] args) { int a,b,c; for (c = 710; c >= 1; c--) { for (b = c-1; b >= 1; b--) { a = 1000-c-b; if (a>0 && a<b && c * c == a * a +b * b ) { Console.WriteLine("result:{0}",a*b*c); Console.ReadLine(); } } } }
结果:31875000