A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
For example,
There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.
cevap : 31875000
#include <stdio.h>
#include <math.h>
#pragma hdrstop
#include <tchar.h>
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
unsigned int a,b,c,multiplication;
for (a = 1; a < 1000; ++a)
{
b = (500000-1000*a)/(1000-a);
c = sqrt(a*a + b*b);
if ((a+b+c) == 1000)
{
break;
}
}
multiplication = a*b*c;
return 0;
}