SHARE
TWEET

Untitled

a guest Jun 24th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool IsPrime(BigInteger Num)
  2.         {
  3.             if (Num < 2) return false;
  4.             else if (Num < 4) return true;
  5.             else if (Num % 2 == 0) return false;
  6.             else for (BigInteger u = 3; u * u <= Num; u += 2)
  7.                     if (Num % u == 0) return false;
  8.             return true;
  9.         }
  10.      
  11. bool IsPrimeBetter(BigInteger Num)
  12.         {
  13.             ulong arrayLe = (ulong)Isqrt((long)Num);
  14.             if (Num < 2) return false;
  15.             else if (Num < 4) return true;
  16.             else foreach (var prime in new Atkin(arrayLe))
  17.                     if (Num % prime == 0) return false;
  18.             return true;
  19.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top