No is prime or not

First of all, I want to tell you that what is the prime no.

Prime no is the no which can’t be divided by other than 1 and itself.

Prime No? Yes : No;

  1. (adsbygoogle = window.adsbygoogle || []).push({});
  2.  
  3. <?php
  4. $no=8;
  5. $prime=true;
  6. for($i=2;$i<($no/2);$i++)
  7. {
  8. if($no%$i==0){
  9. $prime=false;
  10. break;
  11. }
  12. }
  13. if($prime==true){
  14. echo "<br/>Number is Prime<br/>";
  15. }
  16. else{
  17. echo "<br/>Number is not prime<br/>";
  18. }
  19. ?>

 

Leave a Reply