This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A387396 #23 Aug 30 2025 10:26:07 %S A387396 1,2,12,22,72,84,168,264,252,756,504,672,1260,1512,2184,2640,2772, %T A387396 2016,2520,4032,5544,5040,6048,6720,7392,13104,12096,16632,10080, %U A387396 15120,18144,21840,33600,25200,34320,22176,20160,34272,30240,42840,45360,36960,50400,52416,55440,94248,65520,66528,60480 %N A387396 a(n) is the smallest positive number with a total of exactly n 2's in the decimal digits of its divisors. %C A387396 a(n) is the least number k such that A387394(k) = n. %H A387396 Robert Israel, <a href="/A387396/b387396.txt">Table of n, a(n) for n = 0..371</a> %F A387396 A387394(a(n)) = n. %e A387396 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. %p A387396 ff:= proc(n) option remember; numboccur(2, convert(n, base, 10)) end proc: %p A387396 f:= proc(n) local d; add(ff(d), d=numtheory:-divisors(n)) end proc: %p A387396 V:= Array(0..50): count:= 0: %p A387396 for x from 1 while count < 51 do %p A387396 v:= f(x); if v <= 50 and V[v] = 0 then V[v]:= x; count:= count+1; fi %p A387396 od: %p A387396 convert(V,list); %t A387396 a[n_]:=Module[{k=1}, While[Count[IntegerDigits[Divisors[k]]//Flatten, 2]!=n, k++]; k]; Array[a, 49,0] (* _Stefano Spezia_, Aug 29 2025 *) %o A387396 (PARI) f(n) = sumdiv(n, d, #select(x->(x==2), digits(d))); \\ A387394 %o A387396 a(n) = my(k=1); while(f(k) !=n, k++); k; \\ _Michel Marcus_, Aug 28 2025 %o A387396 (Python) %o A387396 from itertools import count, islice %o A387396 def f(n): return sum(str(d).count("2") for d in divisors(n, generator=True)) %o A387396 def agen(): # generator of terms %o A387396 n, adict = 0, dict() %o A387396 for k in count(1): %o A387396 v = f(k) %o A387396 if v not in adict: %o A387396 adict[v] = k %o A387396 while n in adict: yield adict[n]; n += 1 %o A387396 print(list(islice(agen(), 50))) # _Michael S. Branicky_, Aug 29 2025 %Y A387396 Cf. A387357, A387394, A387464. %K A387396 nonn,base,new %O A387396 0,2 %A A387396 _Robert Israel_, Aug 28 2025