prime number in php

Solutions on MaxInterview for prime number in php by the best coders in the world

showing results for - "prime number in php"
Moritz
02 Aug 2018
1<?php
2function IsPrime($n)
3{
4 for($x=2; $x<$n; $x++)
5   {
6      if($n %$x ==0)
7	      {
8		   return 0;
9		  }
10    }
11  return 1;
12   }
13$a = IsPrime(3);
14if ($a==0)
15echo 'This is not a Prime Number.....'."\n";
16else
17echo 'This is a Prime Number..'."\n";
18?>
19
20