Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Fast factorial modulo a given number
Compute a factorial modulo 53:
In[1]:= | ![]() |
Out[1]= | ![]() |
Check the result:
In[2]:= | ![]() |
Out[2]= | ![]() |
Work with a nonprime modulus:
In[3]:= | ![]() |
Out[3]= | ![]() |
The simple algorithm is slow:
In[4]:= | ![]() |
Out[4]= | ![]() |
A native speed up is two times faster:
In[5]:= | ![]() |
Out[5]= | ![]() |
NTT speed up is four times faster:
In[6]:= | ![]() |
Out[6]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License