Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save developer-anuragsingh/a4cbb26b40731470cd5e to your computer and use it in GitHub Desktop.
Save developer-anuragsingh/a4cbb26b40731470cd5e to your computer and use it in GitHub Desktop.
Find all the Prime numbers with the PHP function
<?php
function find_prime_nums($start, $end){
for($i=$start; $i<=$end; $i++){
$counter = 0;
for($j=1; $j<=$i; $j++){
if($i%$j == 0){
$counter++;
}
}
if($counter == 2) {
echo "$i - is a prime number. <br/>";
}
}
}
find_prime_nums(2,10);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment