OFFSET
0,2
COMMENTS
a(n) is the least number k such that A387394(k) = n.
LINKS
Robert Israel, Table of n, a(n) for n = 0..371
FORMULA
A387394(a(n)) = n.
EXAMPLE
a(3) = 22 because of the divisors of 22, 2 has one 2, 22 has two, for a total of 3, and 22 is the smallest number that works.
MAPLE
ff:= proc(n) option remember; numboccur(2, convert(n, base, 10)) end proc:
f:= proc(n) local d; add(ff(d), d=numtheory:-divisors(n)) end proc:
V:= Array(0..50): count:= 0:
for x from 1 while count < 51 do
v:= f(x); if v <= 50 and V[v] = 0 then V[v]:= x; count:= count+1; fi
od:
convert(V, list);
MATHEMATICA
a[n_]:=Module[{k=1}, While[Count[IntegerDigits[Divisors[k]]//Flatten, 2]!=n, k++]; k]; Array[a, 49, 0] (* Stefano Spezia, Aug 29 2025 *)
PROG
(PARI) f(n) = sumdiv(n, d, #select(x->(x==2), digits(d))); \\ A387394
a(n) = my(k=1); while(f(k) !=n, k++); k; \\ Michel Marcus, Aug 28 2025
(Python)
from sympy import divisors
from itertools import count, islice
def f(n): return sum(str(d).count("2") for d in divisors(n, generator=True))
def agen(): # generator of terms
n, adict = 0, dict()
for k in count(1):
v = f(k)
if v not in adict:
adict[v] = k
while n in adict: yield adict[n]; n += 1
print(list(islice(agen(), 50))) # Michael S. Branicky, Aug 29 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Robert Israel, Aug 28 2025
STATUS
approved
