diff --git a/ProjectEuler/033/problem33.php b/ProjectEuler/033/solve.php similarity index 100% rename from ProjectEuler/033/problem33.php rename to ProjectEuler/033/solve.php diff --git a/ProjectEuler/035/problem35.php b/ProjectEuler/035/problem35.php deleted file mode 100644 index f087cd1..0000000 --- a/ProjectEuler/035/problem35.php +++ /dev/null @@ -1,61 +0,0 @@ -= 1000000) - break; - //If there's an even digit (or a 5) we can instantly exclude it as when rotated it will not not be a prime. - if ( - strpos((string) $data[1], "0") !== false || - strpos((string) $data[1], "2") !== false || - strpos((string) $data[1], "4") !== false || - strpos((string) $data[1], "5") !== false || - strpos((string) $data[1], "6") !== false || - strpos((string) $data[1], "8") !== false - ) { - - continue; - } - $primes[] = (int) $data[1]; - } - fclose($handle); -} -echo "File read\n"; - -$count = 1+1; //2 and 5 are primes but not included -foreach($primes as $prime) -{ - //echo "Now testing $prime\n"; - $newprime = $prime; - for($rotate = 1; $rotate < strlen($prime); $rotate++) - { - $newprime = substr($newprime, -1, 1).substr($newprime, 0, -1); - //echo "New prime: $newprime\n"; - if(!in_array($newprime, $primes)) - { - continue 2; - } - - } - $count++; - echo $prime.PHP_EOL; - - -} - -echo "Total: $count\n"; \ No newline at end of file diff --git a/ProjectEuler/035/solve.php b/ProjectEuler/035/solve.php index 04ba96e..f087cd1 100644 --- a/ProjectEuler/035/solve.php +++ b/ProjectEuler/035/solve.php @@ -1,40 +1,61 @@ -= 1000000) + break; + //If there's an even digit (or a 5) we can instantly exclude it as when rotated it will not not be a prime. + if ( + strpos((string) $data[1], "0") !== false || + strpos((string) $data[1], "2") !== false || + strpos((string) $data[1], "4") !== false || + strpos((string) $data[1], "5") !== false || + strpos((string) $data[1], "6") !== false || + strpos((string) $data[1], "8") !== false + ) { + + continue; + } + $primes[] = (int) $data[1]; + } + fclose($handle); +} +echo "File read\n"; + +$count = 1+1; //2 and 5 are primes but not included +foreach($primes as $prime) +{ + //echo "Now testing $prime\n"; + $newprime = $prime; + for($rotate = 1; $rotate < strlen($prime); $rotate++) + { + $newprime = substr($newprime, -1, 1).substr($newprime, 0, -1); + //echo "New prime: $newprime\n"; + if(!in_array($newprime, $primes)) + { + continue 2; + } + + } + $count++; + echo $prime.PHP_EOL; + + +} + +echo "Total: $count\n"; \ No newline at end of file diff --git a/ProjectEuler/045/problem45.php b/ProjectEuler/045/solve.php similarity index 100% rename from ProjectEuler/045/problem45.php rename to ProjectEuler/045/solve.php