Last active
February 26, 2018 15:33
-
-
Save arvindsvt/31e770f0a5d0809bc6beef7b95325294 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| error_reporting(E_ALL); | |
| $num =23; | |
| for( $j = 2; $j <= $num; $j++ ) | |
| { | |
| for( $k = 2; $k < $j; $k++ ) | |
| { | |
| if( $j % $k == 0 ) | |
| { | |
| break; | |
| } | |
| } | |
| if( $k == $j ) | |
| echo 'Prime Number : ', $j, '; | |
| } | |
| ?> | |
| <?php | |
| function IsPrime($n) | |
| { | |
| for($x=2; $x<$n; $x++) | |
| { | |
| if($n %$x ==0) | |
| { | |
| return 0; | |
| } | |
| } | |
| return 1; | |
| } | |
| $a = IsPrime(3); | |
| if ($a==0) | |
| echo 'This is not a Prime Number.....'."\n"; | |
| else | |
| echo 'This is a Prime Number..'."\n"; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment