OFFSET
1,12
COMMENTS
Inspired by Project Euler, Problem 474 (see link).
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.
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.
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
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Project Euler, Problem 474: Last digits of divisors.
FORMULA
For 1-digit numbers: a(n) = 1.
For 2-digit numbers: a(n) = 0 iff n is odd, a(n) >= 1 if n is even.
For 4-digit numbers: a(n) = 0 if n is odd.
For 5-digit numbers, a(n) >= 2 if n ends with 5, a(n) >=1 if n ends with 0, otherwise a(n) = 0.
For 8-digit numbers, a(n) = 0 if n is odd.
EXAMPLE
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.
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.
MAPLE
f:= proc(n) local d, dd;
d:= ilog10(n)+1;
dd:= ilog10(d)+1;
nops(select(t -> t mod 10^dd = d, numtheory:-divisors(n)))
end proc:
map(f, [$1..100]); # Robert Israel, Nov 12 2020
MATHEMATICA
a[n_] := DivisorSum[n, 1 &, Divisible [# - (ndigit = IntegerLength[n]), 10^IntegerLength[ndigit]] &]; Array[a, 100] (* Amiram Eldar, Nov 12 2020 *)
PROG
(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
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Nov 11 2020
EXTENSIONS
Name generalized following remark of Marius A. Burtea, Nov 12 2020
STATUS
approved