login
A387394
Total number of 2's in the decimal digits of the divisors of n.
4
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 1, 0, 1, 0, 1, 0, 2, 1, 3, 1, 3, 1, 2, 1, 2, 1, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 3, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 3, 0, 2, 1, 2, 0, 3, 0, 1, 1, 1, 0, 4, 0, 1, 1, 1, 0, 2, 0, 2, 1, 2, 0, 5, 0, 1, 1, 3, 0, 1, 0, 3, 0, 1, 0, 4, 0, 1, 0
OFFSET
1,12
LINKS
EXAMPLE
a(22) = 3 because among the divisors of 22, 2 has one 2 and 22 has two, for a total of 3.
MAPLE
f:= proc(n) local d; add(numboccur(2, convert(d, base, 10)), d=numtheory:-divisors(n)) end proc:
map(f, [$1..200]);
MATHEMATICA
a[n_]:=Count[IntegerDigits[Divisors[n]]//Flatten, 2]; Array[a, 99] (* Stefano Spezia, Aug 29 2025 *)
PROG
(PARI) a(n) = sumdiv(n, d, #select(x->(x==2), digits(d))); \\ Michel Marcus, Aug 28 2025
(Python)
from sympy import divisors
def a(n): return sum(str(d).count("2") for d in divisors(n, generator=True))
print([a(n) for n in range(1, 100)]) # Michael S. Branicky, Aug 29 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Robert Israel, Aug 28 2025
STATUS
approved