login
Last digit of the product of decimal digits of n.
2

%I #31 Mar 22 2024 20:08:21

%S 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,2,4,6,8,0,2,4,6,8,0,3,6,9,

%T 2,5,8,1,4,7,0,4,8,2,6,0,4,8,2,6,0,5,0,5,0,5,0,5,0,5,0,6,2,8,4,0,6,2,

%U 8,4,0,7,4,1,8,5,2,9,6,3,0,8,6,4,2,0,8,6,4,2,0,9,8

%N Last digit of the product of decimal digits of n.

%C n=0 is taken as one 0 digit so that its product of digits is A007954(0) = 0.

%H Alois P. Heinz, <a href="/A371281/b371281.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) = A007954(n) mod 10.

%F a(n) = A010879(A007954(n)).

%e n = 15: a(15) = 1*5 mod 10 = 5.

%e n = 26: a(26) = 2*6 mod 10 = 2.

%p a:= n-> `if`(n<10, n, irem(n, 10, 'q')*a(q) mod 10):

%p seq(a(n), n=0..92); # _Alois P. Heinz_, Mar 17 2024

%t a[n_] := Mod[Times @@ IntegerDigits[n], 10]; Array[a, 100, 0] (* _Amiram Eldar_, Mar 17 2024 *)

%o (Python)

%o from math import prod

%o def a(n): return prod(map(int, str(n)))%10

%o print([a(n) for n in range(93)]) # _Michael S. Branicky_, Mar 17 2024

%o (PARI) a(n) = if (n==0, 0, vecprod(digits(n)) % 10); \\ _Michel Marcus_, Mar 17 2024

%Y Cf. A007954, A010879, A036987 (similar for 2 instead of 10), A053837.

%K nonn,base

%O 0,3

%A _Ctibor O. Zizka_, Mar 17 2024