login
A071358
Least k>0 such that the last digit of (n+k)^n is the same as the last digit of n^n.
0
10, 6, 10, 2, 10, 8, 10, 4, 10, 10, 10, 2, 10, 2, 10, 2, 10, 4, 10, 10, 10, 6, 10, 2, 10, 8, 10, 4, 10, 10, 10, 2, 10, 2, 10, 2, 10, 4, 10, 10, 10, 6, 10, 2, 10, 8, 10, 4, 10, 10, 10, 2, 10, 2, 10, 2, 10, 4, 10, 10, 10, 6, 10, 2, 10, 8, 10, 4, 10, 10, 10, 2, 10, 2, 10, 2, 10, 4, 10, 10
OFFSET
1,1
LINKS
FORMULA
a(n) is periodic with period (10, 6, 10, 2, 10, 8, 10, 4, 10, 10, 10, 2, 10, 2, 10, 2, 10, 4, 10, 10) of length 20
MATHEMATICA
LinearRecurrence[{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {10, 6, 10, 2, 10, 8, 10, 4, 10, 10, 10, 2, 10, 2, 10, 2, 10, 4, 10, 10}, 80] (* Ray Chandler, Aug 26 2015 *)
PROG
(PARI) a(n)=if(n<0, 0, s=1; while(abs((n+s)^n%10-n^n%10)>0, s++); s)
(Python)
def a(n):
k, target = 2, pow(n, n, 10)
while pow(n+k, n, 10) != target: k += 2
return k
print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Oct 06 2021
CROSSREFS
Sequence in context: A304879 A105155 A072930 * A167873 A369702 A033986
KEYWORD
easy,nonn,base
AUTHOR
Benoit Cloitre, Aug 13 2002
STATUS
approved