Euler/euler9.php

25 lines
376 B
PHP
Raw Normal View History

2015-11-15 00:34:56 +01:00
<?php
/*
* Gnieark's anwser to euler problem 9
* https://projecteuler.net/problem=9
*/
/*
+=
a+b+c=1000
so a+b+sqrt(+) = 1000
and
>
a<c<1000
a and b <500
*/
for($a=1;$a<501;$a++){
for($b=1;$b<501;$b++){
if($a+$b+sqrt(pow($a,2)+pow($b,2)) == 1000){
echo ($a*$b*sqrt(pow($a,2)+pow($b,2)));
break 2;
}
}
}