%I #61 Sep 08 2022 08:46:25
%S 1,1,1,1,1,1,1,1,1,1,0,2,0,1,0,1,0,1,0,1,0,2,0,2,0,1,0,1,0,1,0,2,0,1,
%T 0,2,0,1,0,1,0,2,0,2,0,1,0,2,0,1,0,2,0,1,0,1,0,1,0,2,0,2,0,2,0,2,0,1,
%U 0,1,0,3,0,1,0,1,0,1,0,1,0,2,0,3,0,1,0,2,0,1,0
%N a(n) is the number of divisors of n whose last digits equal the number of digits of n.
%C Inspired by Project Euler, Problem 474 (see link).
%C If in the name, one replaces “whose last digits equal” with “whose last digit equals” then, this sequence is finite and the last term should be a(999999999) = 5 because 999999999 has 9 digits and among the 20 divisors of 999999999, five of them (9, 999, 9009009, 12345679 and 999999999) have the last digit 9.
%C With this name, the next term is a(10^9) = 1 because 10^9 has 10 digits and among the 100 divisors of 10^9, only one of them (10) ends with 10.
%C For p prime, p >= 7, the number 10^(p - 1) + p - 1 is divisible by p and the number of digits is p, so it has at least one divisor that ends in p. Thus, there is an infinity of terms a(k) > 0. - _Marius A. Burtea_, Nov 12 2020
%H Robert Israel, <a href="/A338822/b338822.txt">Table of n, a(n) for n = 1..10000</a>
%H Project Euler, <a href="https://projecteuler.net/problem=474">Problem 474: Last digits of divisors</a>.
%F For 1-digit numbers: a(n) = 1.
%F For 2-digit numbers: a(n) = 0 iff n is odd, a(n) >= 1 if n is even.
%F For 4-digit numbers: a(n) = 0 if n is odd.
%F For 5-digit numbers, a(n) >= 2 if n ends with 5, a(n) >=1 if n ends with 0, otherwise a(n) = 0.
%F For 8-digit numbers, a(n) = 0 if n is odd.
%e 72 has 2 digits, and among the divisors of 72 (1, 2, 3, 4, 6, 12, 18, 24, 36, 72), three of them (2, 12 and 72) have the last digit 2, hence a(72) = 3.
%e 111 has 3 digits, and among the divisors of 111 (1, 3, 37, 111), only one of them (3) has the last digit 3, hence a(111) = 1.
%p f:= proc(n) local d, dd;
%p d:= ilog10(n)+1;
%p dd:= ilog10(d)+1;
%p nops(select(t -> t mod 10^dd = d, numtheory:-divisors(n)))
%p end proc:
%p map(f, [$1..100]); # _Robert Israel_, Nov 12 2020
%t a[n_] := DivisorSum[n, 1 &, Divisible [# - (ndigit = IntegerLength[n]), 10^IntegerLength[ndigit]] &]; Array[a, 100] (* _Amiram Eldar_, Nov 12 2020 *)
%o (Magma) [#[d:d in Divisors(n) | d mod 10^(#Intseq(#Intseq(n))) eq #Intseq(n)]:n in [1..100]]; // _Marius A. Burtea_, Nov 12 2020
%o (PARI) a(n) = my(nb = #Str(n), nc = #Str(nb)); sumdiv(n, d, if (d<nb, 0, !((d-nb) % (10^nc)))); \\ _Michel Marcus_, Nov 16 2020
%Y Cf. A000005, A330348.
%K nonn,base
%O 1,12
%A _Bernard Schott_, Nov 11 2020
%E Name generalized following remark of _Marius A. Burtea_, Nov 12 2020