OFFSET
1,1
LINKS
Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1).
FORMULA
a(n) is periodic with period (10, 16, 14, 2, 10, 2, 6, 4, 10, 10, 10, 2, 14, 2, 10, 8, 6, 4, 10, 10, 10) of length 20
MATHEMATICA
ld[n_]:=Module[{ldn=Mod[n^n, 10], k=1}, While[Mod[(n+k)^(n+k), 10] != ldn, k++]; k]; Array[ld, 90] (* Harvey P. Dale, Sep 07 2012 *)
LinearRecurrence[{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {10, 16, 14, 2, 10, 2, 6, 4, 10, 10, 10, 2, 14, 2, 10, 8, 6, 4, 10, 10}, 81] (* Ray Chandler, Aug 26 2015 *)
PROG
(PARI) a(n)=if(n<0, 0, s=1; while(abs((n+s)^(n+s)%10-n^n%10)>0, s++); s)
(Python)
def a(n):
k, target = 1, pow(n, n, 10)
while pow(n+k, n+k, 10) != target: k += 1
return k
print([a(n) for n in range(1, 82)]) # Michael S. Branicky, Oct 16 2021
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Benoit Cloitre, Aug 13 2002
STATUS
approved