Solved ProjectEuler/039,041,042
This commit is contained in:
20
ProjectEuler/039/solve.php
Normal file
20
ProjectEuler/039/solve.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
define('P_VALUE',1000);
|
||||
|
||||
for($p=2;$p<P_VALUE;$p++) {
|
||||
|
||||
for($a=2;$a<$p;$a++) {
|
||||
for($b=$a;$b<$p;$b++) {
|
||||
//Find C so it runs faster...
|
||||
$c = $p - $a - $b;
|
||||
if($a*$a+$b*$b == $c*$c) {
|
||||
$result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($result > $max) {
|
||||
$max = $result; $key = $p;
|
||||
}
|
||||
$result = 0;
|
||||
}
|
||||
echo $key;
|
Reference in New Issue
Block a user