Advertisement
DraKiNs

[COD] IsPrime V2

Jun 30th, 2011
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.31 KB | None | 0 0
  1. function IsPrime($iValor)
  2. {
  3.     $iCount = 4;
  4.  
  5.     if( ($iValor == 2) || ($iValor == 3) ) return true;
  6.     if( !($iValor % 2) || !($iValor % 3) || !($iValor % 4) || ($iValor == 1)) return false;
  7.  
  8.     while(++$iCount <= sqrt($iValor))
  9.         if( !($iValor % $iCount) && ($iValor != $iCount) ) return false;
  10.  
  11.     return true;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement