Revision: 13470
Updated Code
at April 24, 2009 19:33 by cobra90nj
Updated Code
<?php define('N', 200); function isPrime($num) { if ($num == 2 || $num == 3) { return 1; } if (!($num%2) || $num<1) { return 0; } for ($n = 3; $n <= $num/2; $n += 2) { if (!($num%$n)) { return 0; } } return 1; } for ($i = 2; $i <= N; $i++) { if (isPrime($i)) { $sum += $i; } } echo $sum;
Revision: 13469
Updated Code
at April 24, 2009 19:33 by cobra90nj
Updated Code
<?php define('N', 200); function isPrime($num) { if ($num == 2 || $num == 3) { return 1; } if (!($num%2) || $num<1) { return 0; } for ($n = 3; $n <= $num/2; $n += 2) { if (!($num%$n)) { return 0; } } return 1; } for ($i = 2; $i <= N; $i++) { if (isPrime($i)) { $sum += $i; } } echo $sum;
Revision: 13468
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 24, 2009 19:25 by cobra90nj
Initial Code
<?php define('N', 200); function isPrime($num) { if ($num<1) { return 0; } if ($num == 2) { return 1; } if ($num == 3) { return 1; } if (!($num%2)) { return 0; } for ($n = 3; $n <= $num/2; $n += 2) { if (!($num%$n)) { return 0; } } return 1; } for ($i = 2; $i <= N; $i++) { if (isPrime($i)) { $sum += $i; } } echo $sum;
Initial URL
Initial Description
Initial Title
Sum the number prime
Initial Tags
php, number
Initial Language
PHP