diff --git a/2017-04-11/ikselven_euler87-foreach.php b/2017-04-11/ikselven_euler87-foreach.php new file mode 100755 index 0000000..f1dd008 --- /dev/null +++ b/2017-04-11/ikselven_euler87-foreach.php @@ -0,0 +1,35 @@ +#!/usr/bin/php += MAX) { + break; + } + + foreach($primes as $middle) { + $cube = $fourth + $middle ** 3; + if ($cube >= MAX) { + break; + } + + foreach($primes as $inner) { + $sum = $cube + $inner ** 2; + if ($sum >= MAX) { + break; + } + $sums[] = $sum; + } + } +} + +echo "Found ".count(array_unique($sums))." numbers\n"; diff --git a/2017-04-11/ikselven_euler87.php b/2017-04-11/ikselven_euler87.php new file mode 100755 index 0000000..c3fa136 --- /dev/null +++ b/2017-04-11/ikselven_euler87.php @@ -0,0 +1,36 @@ +#!/usr/bin/php += MAX) { + break; + } + + for($middle = 0; $middle < $primeCount; $middle++) { + $cube = $fourth + $primes[$middle] ** 3; + if ($cube >= MAX) { + break; + } + + for($inner = 0; $inner < $primeCount; $inner++) { + $sum = $cube + $primes[$inner] ** 2; + if ($sum >= MAX) { + break; + } + $sums[] = $sum; + } + } +} + +echo "Found ".count(array_unique($sums))." numbers\n";