A command line tool for assisting number theory research, teaching and cryptography subjects.
Runs on Windows, macOS and Linux. Native support for x64 and ARM platforms
View Demo
·
Report Bug
·
Request Feature
Table of Contents
A command line tool for assisting number theory research, teaching and cryptography subjects:
- Factoring a composite given number into its prime factors
- Generating a series of prime numbers of a given range from 1 to 18,446,744,073,709,551,616.
- Calculate the Greatest Common Divisor for a given series of numbers
- Dot Net 9
- VS Code
- Install DotNet if your platform does not already have it.
- Clone this repo.
- Build the project.
- Run "./PrimeFactor --help" for usage instructions.
Install DotNet 9.0 for the platform Windows, macOS or Linux. Intel x64 and Apple Silicon support.
If unsure if Dot Net is install or which version you already have, then open a terminal and run the following command.
dotnet --version
Download and install from:
https://dotnet.microsoft.com/en-us/download- Clone the project's repository
git clone https://github.com/Software101DotNet/PrimeFactor.git
- Build the project
dotnet build -c Release PrimeFactor/PrimeFactor.csproj
- Optionally, run the project's unit tests. Optionally, build the debug version and run the project's unit tests. Depending on the computer, these tests can take a few seconds to several minutes. In the unlikely event that any tests fail, please create a new issue ticket.
dotnet build -c debug PrimeFactor.sln dotnet test xUnitTests/bin/Debug/net9.0/xUnitTests.dll
For upto date usage, Run
./PrimeFactor --help
- [completed v1.0] Prime factoring of given number
- [completed v1.0] Prime number series generation
- [Complated v1.0] support for directing output to a file stream. Usesful for very large series generation.
- [ v2 ] Support for Greatest Common Divisor (supporting a series of more than two values)
- [ v3 ] Support for Perfect Numbers
- [ v4 ] Support for number range 1 to 340,282,366,920,938,463,463,374,607,431,768,211,455 (2^128 bits)
See the open issues for a full list of proposed features (and known issues).
Building PrimeFactor for release using the command line dotnet build --configuration Release and running the benchmark3 100 times with the command ./bin/Release/net9.0/PrimeFactor --benchmark3 1000000 100 reveals a performance side effect. between run 61 and 62, a step change in performance occurs. The median value of run 1 to 61 is 600ms, the median value of run 62 to 100 is 479ms. This is a 20% reduction in time taken to compute the same calculation.
Benchmarking primality test for values between 1 and 1,000,000
Run 1 completed in 632ms
Run 2 completed in 583ms
...
Run 61 completed in 604ms
Run 62 completed in 479ms
...
Run 99 completed in 480ms
Run 100 completed in 478ms
Time to compute each run 478ms ~ 632ms
Running a longer benchmark of 250 runs of a primality test from 1 to 10 million also results in a step change occurring between runs 61 and 62. This is believed to be due to the JIT compiler and the .NET runtime performing hot-path optimisations.
Benchmarking 250 runs, please wait...
Run 1 Benchmarking 10,000,000 primes... Completed in 15s 334ms
Run 2 Benchmarking 10,000,000 primes... Completed in 15s 305ms
...
Run 61 Benchmarking 10,000,000 primes... Completed in 15s 302ms
Run 62 Benchmarking 10,000,000 primes... Completed in 11s 446ms
...
Run 249 Benchmarking 10,000,000 primes... Completed in 11s 471ms
Run 250 Benchmarking 10,000,000 primes... Completed in 11s 502ms
Time to compute 11s 412ms ~ 15s 334ms , median 11s 464ms
This anommally was explored further by creating a C language implementing of the same benchmarks. This sub project can be found in the subfolder PrimeFactorC
If you have any additions or improvements that would make this project better, please fork the repository and create a pull request. You can also simply open an issue with the tag "enhancement". Thanks.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the GPL License. See LICENSE.txt for more information.
Anthony Ransley - software101.net@gmail.com
Project Link: https://github.com/Software101DotNet/PrimeFactor