68. PHP Program to find all the Factorial Prime numbers from 1 to 99.
How does this program work?
- This program is used to find all the factorial prime numbers from 1 to 99 using PHP.
- Prime number means which is only divisible by 1 and that number itself, and cannot divisible by any other number.
- First store the number into variable, then we will find the remainder using loop.
- The counter will be increment if remainder zero, Once number can be divisible by some other number instead of 1 and that number itself, If its value less than three means its a primer number.
Here is the code
<html>
<head>
<title>PHP Program To find all the factorial prime numbers from 1 to 99</title>
</head>
<body>
<?php
$sum = 0;
for($i= 2; $i<= 5; ++$i )
{
$count = 0;
for($k=2; $k<=$i/2; $k++)
{
if( ($i % $k) == 0)
{
$count++;
}
}
if($count==0)
{
$fact = 1;
for($j=1;$j<=$i;$j++)
{
$fact*=$j;
}
$sum+=$fact;
}
}
echo(" Sum of prime numbers factorial is: ".$sum);
return 0;
?>
</body>
</html>