Skip to content

Instantly share code, notes, and snippets.

@moff
Created February 28, 2017 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moff/0c8fa3df50ca50c2167d0aa33c20e399 to your computer and use it in GitHub Desktop.
Save moff/0c8fa3df50ca50c2167d0aa33c20e399 to your computer and use it in GitHub Desktop.
<?php
$start = 2;
$end = 200;
$index = 1;
$sum = 0;
for($i = $start; $i <= $end; $i++)
{
for($j = 2; $j < $i; $j++)
{
if ($i % $j == 0) break;
}
if ($j == $i) {
$sum += $index * $i;
$index++;
}
}
echo $sum . PHP_EOL;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment