There are five algorithms which everyone who wants to compute the factorial n! = 1.2.3...n should know.

An example of a PrimeSwing computation:

As this example shows an efficient computation of the factorial function reduces to an efficient computation of the swinging factorial n≀. Some information about these numbers can be found here and here. The prime factorization of the swing numbers is crucial for the implementation of the PrimeSwing algorithm.

A concise description of this algorithm is given in this write-up (pdf) and in the SageMath link below (Algo 5).