Check number is prime or not in php

technical talkiess
0

 <?php

function primeNumberCheck($number){

if($number == 1){

return 0;

}


for($i=2;$i<= $number /2 ; $i++){

if($number%$i == 0){

return 0;

}

}

return 1;

}

$number = 1212121212121212;

if(primeNumberCheck($number)){

echo "prime number";

}else{

echo "Not a Prime Number";

}

?> 

Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)