Skip to content

ExtendedNumerics.Helpers.BigIntegerHelper.FastFactorial

Adam White edited this page Oct 7, 2024 · 1 revision

BigIntegerHelper.FastFactorial Class

Calculates a factorial by the divide and conquer method.
This is faster than repeatedly multiplying the next value by a running product
by not repeatedly multiplying by large values.
Essentially, this multiplies every number in the array with its neighbor,
returning an array half as long of products of two numbers.
We then take that array and multiply each pair of values in the array
with its neighbor, resulting in another array half the length of the previous one, and so on...
This results in many multiplications of small, equally sized operands
and only a few multiplications of larger operands.
In the limit, this is more efficient.

The factorial function is used during the calculation of trigonometric functions to arbitrary precision.

public static class BigIntegerHelper.FastFactorial

Inheritance System.Object 🡒 FastFactorial

Clone this wiki locally