public static bool SolovayStrassen(ulong n)
 {
     for (ulong a = 2; a < n; a++)
     {
         if (!Problably.EulerJacobi(n, a))
         {
             return(false);
         }
     }
     return(true);
 }
 public static bool Fermat(ulong n)
 {
     for (ulong a = 2; a < n - 1; a++)
     {
         if (GCD.Standard(n, a) != 1 && !Problably.Fermat(n, a))
         {
             return(false);
         }
     }
     return(true);
 }
 public static bool SolovayStrassen(ulong n, ulong iterations)
 {
     for (ulong i = 0; i < iterations; i++)
     {
         if (!Problably.EulerJacobi(n, (ulong)random.Next(2, (int)n)))
         {
             return(false);
         }
     }
     return(true);
 }
 public static bool Fermat(ulong n, ulong iterations)
 {
     for (ulong i = 0, a = (ulong)random.Next(2, (int)(n - 1)); i < iterations; i++, a = (ulong)random.Next(2, (int)(n - 1)))
     {
         if (GCD.Standard(n, a) != 1 && !Problably.Fermat(n, a))
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #5
0
 public static bool BailliePSW(ulong n) => Problably.Strong(n, 2) && Problably.StrongLucas(n);
Exemple #6
0
 public static bool Selfridge(ulong n) => Problably.Fermat(n, 2) && Problably.FibonacciAlternative(n);