shahmoradi / Fast-Factorial-Functions

Swing, divide and conquer the factorial!

Home Page:http://www.luschny.de/math/factorial/FastFactorialFunctions.htm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fast Factorial Functions

Project status: maintained and up-to-date.

Here you can find implementations of the most efficient algorithms to compute

See also this nice overview.

Short guide:

Implementation languages

  • Project MpirBasedFunctions : C++
  • Project SilverFactorial64 : C#
  • Project JavaFactorial : Java
  • Project GoFactorial : Go
  • Project SageMathFactorial : SageMath
  • Project PyFactorial : Python
  • Project JFactorial : Julia

The C# and the Java version come with a small benchmark program. Here a screenshot of the Java version and a screenshot of the C# version.

Browsing the code

To browse the code the following two pages might be more convenient: primes and factorials.

Porting

If you want to port the algorithms to other languages the C# version is recommended as the point of departure. The benchmarks indicate that it is a good idea to start with the swing algorithm or (more demanding to implement, but at least twice as fast) the prime swing algorithm.

A good starting point for the binomial function is here.

Dependencies

To build the sources you need for

  • the C++ version the MPIR library.

  • The C# version uses the MPIR library (an interop is provided).

  • The Java version needs Mikko Tommila's Apfloat library. If you want to compile the benchmark program additionally Karsten Lentzsch's JGoodies is needed.

Contributing

Please notify me of any bugs. Want to contribute new algorithms? Great, please contact me. If you already ported to some other language (Scala, F#, Rust, Ruby, Lisp) then please send me your code so I can incorporate it into this repository.

Contributors

Sonia Keys ported the algorithms to Go.

Michael Saupe contributed a performance optimized python3 version with gmpy2.

About

Swing, divide and conquer the factorial!

http://www.luschny.de/math/factorial/FastFactorialFunctions.htm

License:MIT License


Languages

Language:C# 46.9%Language:Java 33.7%Language:C++ 8.7%Language:Go 5.6%Language:Python 2.3%Language:Julia 1.1%Language:Perl 0.8%Language:Jupyter Notebook 0.8%Language:Makefile 0.1%