Function Repository Resource:

TetrationMod

Source Notebook

Get the mod value of large exponential towers

Contributed by: Trevor Cappallo

ResourceFunction["TetrationMod"][n,h,m]

returns the value of an exponential integer tower of value n and height h, taken mod m.

Details

All arguments must be positive integers.
h cannot be larger than $RecursionLimit, but ResourceFunction["TetrationMod"] typically converges at an h value far smaller than that. If necessary for some reason, you can increase your $RecursionLimit to allow a larger h.

Examples

Basic Examples (1) 

in standard tetration notation. Find :

In[1]:=
ResourceFunction["TetrationMod"][3, 4, 1000]
Out[1]=

Scope (1) 

TetrationMod allows fast evaluation of large arguments that would not be otherwise possible using Mod or PowerMod:

In[2]:=
ResourceFunction["TetrationMod"][1234567890123456789, 300, 65536] // Timing
Out[2]=

Applications (1) 

will not change for all hc, where c is a relatively small constant depending on n and m:

In[3]:=
ResourceFunction["TetrationMod"][13578, #, 151] & /@ Range[10]
Out[3]=

This means that even infinitely tall power towers have well-defined mod values for a given n, m.

Neat Examples (2) 

Find the last 10 digits of the exponential tower 202120212021, which is 1000 terms high:

In[4]:=
ResourceFunction["TetrationMod"][2021, 1000, 10^10]
Out[4]=

In fact, you can see this will converge after reaching a height of 9:

In[5]:=
{#, ResourceFunction["TetrationMod"][2021, #, 10^10]} & /@ Range@15 // TableForm
Out[5]=

Publisher

Trevor Cappallo

Version History

  • 1.0.0 – 20 September 2021

Related Resources

Author Notes

Note that h is the primary computational bottleneck, so keeping it small whenever possible is ideal.

License Information