-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
32 lines (29 loc) · 851 Bytes
/
Copy pathindex.php
File metadata and controls
32 lines (29 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/*
|------------------------------------------------------
| Prime number function
|-------------------------------------------------------
*/
function PHPPrimeNumber($startnumber,$endnumber){
$totalPrime=0;
$sumPrime=0;
for($i=$startnumber;$i<=$endnumber;$i++){
$flag=0;
for($x=2; $x<=$i/2; $x++){
if($i % $x==0){
$flag++;
break;
}
}
if($flag==0){
$sumPrime=+$i." prime <br/>";
$totalPrime+=1;
}
}
echo "Prime Number of 0-100000 number. note:- for one-million number execution time out<br/>";
echo "Total Prime number= ".$totalPrime."<br/>";
echo "Sum of Prime number= ".$sumPrime;
}
/* call function */
PHPPrimeNumber(1,100000)
?>