Methods and extensions for prime number detection and discovery.
using Open.Numeric.Primes;
Number.IsPrime(8592868089022906369); // true
Prime.Factors(12); // 2, 2, 3
Prime.CommonFactors(84, 756, 108); // 2, 2, 3
Prime.GreatestFactor(84, 756, 108); // 12
// Will list the first 1000 primes.
foreach(var prime in Prime.Numbers.Take(1000))
{
Console.Write(prime);
}
or
// Will list the first 1000 primes greater than (or equal to) 10,000.
foreach(var prime in Prime.Numbers.StartingAt(10000).Take(100))
{
Console.Write(prime);
}
Extensions are also available for integer types.
using Open.Numeric.Primes.Extensions;
8592868089022906369.IsPrime(); // true