OFFSET
0,2
EXAMPLE
MAPLE
N:= 15: # for terms before the first term >= 3^(N+1)
db:= proc(n) option remember; local L, d, m;
L:= convert(n, base, 3);
d:= nops(L);
d mod 3 = 0 and 3*numboccur(0, L) = d and 3*numboccur(1, L) = d
end proc:
W:= Vector(3^(N+1), datatype=integer[4]):
for d from 3 to N by 3 do
for t from 3^(d-1) to 3^d-1 do
if db(t) then
J:= [seq(i, i=t..3^(N+1), t)];
W[J]:= W[J] +~ 1;
fi
od od:
M:= max(W):
V:= Array(0..M): count:= 0:
for i from 1 to 3^(N+1) while count < M+1 do
if V[W[i]] = 0 then V[W[i]]:= i; count:= count+1 fi;
od:
L:= convert(V, list):
if not member(0, L, 'm') then m:= M+2 fi:
L[1..m-1]; # Robert Israel, Jun 03 2024
MATHEMATICA
balQ[n_, b_] := balQ[n, b] = MinMax@ Differences@ DigitCount[n, b] == {0, 0}; f[n_] := DivisorSum[n, 1 &, balQ[#, 3] &]; seq[len_, nmax_] := Module[{s = Table[0, {len}], c = 0, n = 1, i}, While[c < len && n < nmax, i = f[n] + 1; If[i <= len && s[[i]] == 0, c++; s[[i]] = n]; n++]; s]; seq[12, 10^5] (* Amiram Eldar, Jun 03 2024 *)
PROG
(Magma) bal:=func<n|Multiplicity(Intseq(n, 3), 1) eq Multiplicity(Intseq(n, 3), 0) and Multiplicity(Intseq(n, 3), 1) eq Multiplicity(Intseq(n, 3), 2)>; a:=[]; for n in [0..34] do k:=1; while #[d:d in Divisors(k)|bal(d)] ne n do k:=k+1; end while; Append(~a, k); end for; a;
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Marius A. Burtea, May 23 2024
STATUS
approved