Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/open-net-libraries/open.numeric.primes
- Owner: Open-NET-Libraries
- License: mit
- Created: 2017-09-25T17:50:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-19T17:55:20.000Z (about 1 year ago)
- Last Synced: 2024-05-16T04:35:12.043Z (8 months ago)
- Topics: c-sharp, dotnet-core, prime-detection, prime-discovery, prime-factorizations, prime-factors, prime-generator, prime-numbers, primes
- Language: C#
- Size: 199 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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
```