21 lines
301 B
PHP
21 lines
301 B
PHP
<?php
|
|
|
|
function primeCheck($number){
|
|
if ($number == 1)
|
|
return 0;
|
|
for ($i = 2; $i <= $number/2; $i++){
|
|
if ($number % $i == 0)
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
$sum = 0;
|
|
for($i=2; $i<=1000; $i++)
|
|
{
|
|
if(primeCheck($i)) {
|
|
$sum += $i;
|
|
}
|
|
}
|
|
|
|
echo "Sum: $sum\n"; |