Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/open-net-libraries/open.numeric.primes

Methods and extensions for prime number detection and discovery.
https://github.com/open-net-libraries/open.numeric.primes

c-sharp dotnet-core prime-detection prime-discovery prime-factorizations prime-factors prime-generator prime-numbers primes

Last synced: 1 day ago
JSON representation

Methods and extensions for prime number detection and discovery.

Awesome Lists containing this project

README

        

# Open.Numeric.Primes

Methods and extensions for prime number detection and discovery.

[![NuGet](https://img.shields.io/nuget/v/Open.Numeric.Primes.svg)](https://www.nuget.org/packages/Open.Numeric.Primes/)

## Examples

### Importing
```cs
using Open.Numeric.Primes;
```

### Primality Test

```cs
Number.IsPrime(8592868089022906369); // true
```

### Factors

```cs
Prime.Factors(12); // 2, 2, 3
```

### Common Factors

```cs
Prime.CommonFactors(84, 756, 108); // 2, 2, 3
```

### Greatest Factor

```cs
Prime.GreatestFactor(84, 756, 108); // 12
```

### Prime Discovery

```cs
// Will list the first 1000 primes.
foreach(var prime in Prime.Numbers.Take(1000))
{
Console.Write(prime);
}
```

or

```cs
// 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

Extensions are also available for integer types.

```cs
using Open.Numeric.Primes.Extensions;

8592868089022906369.IsPrime(); // true
```