Skip to content

Instantly share code, notes, and snippets.

@gavinsykes
Created April 29, 2020 21:26
Show Gist options
  • Save gavinsykes/9c4fb0a80b332e164911b9cecfd02895 to your computer and use it in GitHub Desktop.
Save gavinsykes/9c4fb0a80b332e164911b9cecfd02895 to your computer and use it in GitHub Desktop.
<?php
function euler_7($n) {
if ($n < 1 || !is_int($n)) {
return undefined;
}
$r = 0;
$count = 1;
while ($count <= $n) {
if (is_prime(2*$r+1)) {
$count++;
}
$r++;
}
return 2 * $r + 1;
}
$v = $_REQUEST['val'];
echo euler_7($v);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment