Program to find prime numbers in between a range of 100
Prime Number example in PHP. We will print the prime number between a range of 100.The prime number is not divisible by 2 only divisible by 1 and itself.Example
<html> <head> <title>PHP Prime Numbers</title> </head> <body> <?php error_reporting(E_ALL); //Program to find prime numbers in between a range of 100 $num =100; for( $j = 2; $j <= $num; $j++ ) { for( $k = 2; $k < $j; $k++ ) { if( $j % $k == 0 ) { break; } } if( $k == $j ) echo "Prime Number : ", $j, "<br>"; } ?> </body> </html> |
Output
Prime Number : 2
Prime Number : 3
Prime Number : 5
Prime Number : 7
Prime Number : 11
Prime Number : 13
Prime Number : 17
Prime Number : 19
Prime Number : 23
Prime Number : 29
Prime Number : 31
Prime Number : 37
Prime Number : 41
Prime Number : 43
Prime Number : 47
Prime Number : 53
Prime Number : 59
Prime Number : 61
Prime Number : 67
Prime Number : 71
Prime Number : 73
Prime Number : 79
Prime Number : 83
Prime Number : 89
Prime Number : 97
Prime Number : 3
Prime Number : 5
Prime Number : 7
Prime Number : 11
Prime Number : 13
Prime Number : 17
Prime Number : 19
Prime Number : 23
Prime Number : 29
Prime Number : 31
Prime Number : 37
Prime Number : 41
Prime Number : 43
Prime Number : 47
Prime Number : 53
Prime Number : 59
Prime Number : 61
Prime Number : 67
Prime Number : 71
Prime Number : 73
Prime Number : 79
Prime Number : 83
Prime Number : 89
Prime Number : 97
No comments:
Post a Comment