Answers for "Write a php program to accept a number from the user and print whether it is prime or not"

PHP
0

Write a php program to accept a number from the user and print whether it is prime or not

<?php 
$x = 0; 
$number = 2; 
while ($x < 10 ) 
{ 
$div_x=0; 
for ( $i=1; $i<=$number; $i++) 
{ 
if (($number%$i)==0) 
{ 
$div_x++; 
} 
} 
if ($div_x<3) 
{ 
echo $number." , "; 
$x=$x+1; 
} 
$number=$number+1; 
} 
?>
Posted by: Guest on July-05-2021

Code answers related to "Write a php program to accept a number from the user and print whether it is prime or not"

Browse Popular Code Answers by Language