let $(n,q) \in \mathbb N^{*^2}$
I was wondering if it was possible to find a function $f_q$ such that :
$f_q(n)=m$ where $m$ is such that $n^{n^{...^n}} \equiv m \mod q$
or at least an easy way to find m, where $n^{n^{...^n}}$ denotes "infinite" exponentiation, assuming of course it has a "limit" if you see what I mean (that's to say, if you exponentiate long enough, $n^{n^{n^{...^n}}} \equiv m \mod q$, m becomes constant. Is it always the case ? I don't know, but it has to be at least periodic since m belongs somewhere between $0$ and $q-1$... so it has to repeat itself after some exponentiations) To make things easier, let's only consider n for which $n^{n^{n^{...^n}}}$ tends to $m \mod q$ constant
I have made some trials and it seems like it often has a "limit" ($m$ constant)
For example, $f_{10}(7)=3$ since :
$7^7 \equiv 49*49*49*7 \equiv 9*9*9*7 \equiv 81*63 \equiv 3$ mod 20
$7^{3+20k} \equiv 343*(343*343*343*7)^{2k} \equiv 3*(3*3*3*7)^{2k} \equiv 3*81^k \equiv$ 3 mod 20
So $7^{7^{...^7}} \equiv 3$ mod 20, and of course $\equiv 3$ mod 10
I have done this for other numbers, and could provide them with proof but it's a very exhausting process when n becomes big and I couldn't find any obvious pattern...
Sorry if the explanation is a bit messy, the maths I am trying to do isn't very conventional... and probably not very useful either, but I'm still curious... If additional explanation is needed, I'll just edit and add some information
Thanks a lot for anyone ready to help me tackle this not-so-easy arithmetic problem... To be honest I don't think there is a general solution, but I'd be very grateful if someone could find f for even a small subset of $N$.