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 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 #3
0
 public static bool Selfridge(ulong n) => Problably.Fermat(n, 2) && Problably.FibonacciAlternative(n);