Esempio n. 1
0
 public bool IsPrime(int i)
 {
     if (i.IsSquare())
     {
         return(false);
     }
     if (i % 2 == 0)
     {
         return(false ^ (i == 2));
     }
     if (i % 3 == 0)
     {
         return(false ^ (i == 3));
     }
     if (i % 5 == 0)
     {
         return(false ^ (i == 5));
     }
     if (i % 7 == 0)
     {
         return(false ^ (i == 7));
     }
     if (i % 61 == 0)
     {
         return(false ^ (i == 61));
     }
     if (!MillerRabin.MillerRabinPass(2, i))
     {
         return(false);
     }
     return(IsLucasPseudoprime(i));
 }
Esempio n. 2
0
 public bool IsPrime(BigInteger b)
 {
     if (b.IsSquare())
     {
         return(false);
     }
     if (b < long.MaxValue)
     {
         return(IsPrime((long)b));
     }
     if (!MillerRabin.MillerRabinPass(2, b))
     {
         return(false);
     }
     return(IsLucasPseudoprime(b));
 }
Esempio n. 3
0
 public bool IsPrime(long l)
 {
     if (l < int.MaxValue)
     {
         return(IsPrime((int)l));
     }
     if (l.IsSquare())
     {
         return(false);
     }
     if (!MillerRabin.MillerRabinPass(2, l))
     {
         return(false);
     }
     return(IsLucasPseudoprime(l));
 }