A338822 a(n) is the number of divisors of n whose last digits equal the number of digits of n.
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, 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, 0, 1, 0, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 1, 0
Offset: 1
Examples
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.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
- Project Euler, Problem 474: Last digits of divisors.
Programs
-
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
-
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 *)
-
PARI
a(n) = my(nb = #Str(n), nc = #Str(nb)); sumdiv(n, d, if (d
Michel Marcus, Nov 16 2020
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.
Extensions
Name generalized following remark of Marius A. Burtea, Nov 12 2020
Comments