Solve ProjectEuler 049 and 050.
This commit is contained in:
30
solutions/ProjectEuler/049/solve.php
Normal file
30
solutions/ProjectEuler/049/solve.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
include("vendor/autoload.php");
|
||||
|
||||
for($p1 = 1000; $p1<9999-(2*3330); $p1++)
|
||||
{
|
||||
if(CodingTests\Prime::isPrime($p1))
|
||||
{
|
||||
$p2 = $p1 + 3330;
|
||||
if(CodingTests\Prime::isPrime($p2))
|
||||
{
|
||||
$p3 = $p2 + 3330;
|
||||
if(CodingTests\Prime::isPrime($p3))
|
||||
{
|
||||
$p1_occ = count_chars($p1);
|
||||
ksort($p1_occ);
|
||||
$p2_occ = count_chars($p2);
|
||||
ksort($p2_occ);
|
||||
$p3_occ = count_chars($p3);
|
||||
ksort($p3_occ);
|
||||
|
||||
if( $p1_occ == $p2_occ && $p2_occ == $p3_occ)
|
||||
{
|
||||
echo "Permutation $p1$p2$p3\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user