login
Final digit of n^n - n.
0

%I #22 Mar 28 2024 09:01:41

%S 1,0,2,4,2,0,0,6,8,0,0,0,4,0,2,0,0,0,6,0,0,0,2,4,2,0,0,6,8,0,0,0,4,0,

%T 2,0,0,0,6,0,0,0,2,4,2,0,0,6,8,0,0,0,4,0,2,0,0,0,6,0,0,0,2,4,2,0,0,6,

%U 8,0,0,0,4,0,2,0,0,0,6,0,0,0,2,4,2,0,0

%N Final digit of n^n - n.

%C Note: cyclic with a period of 20 for n > 0.

%D R. Euler & J. Sadek, "A number that gives the units of n^n", Journal of Recreational Mathematics 29:3 (1998), pp. 203-204.

%H <a href="/index/Rec#order_20">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1).

%F a(n) = (n^n-n) mod 10

%p [seq((n^n-n) mod 10, n=1..40)];

%t Join[{1}, Table[Mod[PowerMod[n, n, 10] - n, 10], {n, 100}]] (* _T. D. Noe_, Mar 13 2012 *)

%t PadRight[{1},120,{0,0,2,4,2,0,0,6,8,0,0,0,4,0,2,0,0,0,6,0}] (* _Harvey P. Dale_, May 21 2020 *)

%o (Perl) print (($_**$_-$_)%10) for (1..40);

%o (PARI) a(n)=lift(Mod(n,10)^n-n) \\ _Charles R Greathouse IV_, Mar 13 2012

%Y Cf. A056849.

%K nonn,easy,base

%O 0,3

%A _Radu Borza_, Mar 09 2012