OFFSET
1,2
COMMENTS
An unlabeled rooted tree is leaf-balanced if every branch has the same number of leaves and every non-leaf rooted subtree is also leaf-balanced.
MATHEMATICA
nn=2000;
primeMS[n_]:=If[n===1, {}, Flatten[Cases[FactorInteger[n], {p_, k_}:>Table[PrimePi[p], {k}]]]];
leafcount[n_]:=If[n===1, 1, With[{m=primeMS[n]}, If[Length[m]===1, leafcount[First[m]], Total[leafcount/@m]]]];
balQ[n_]:=Or[n===1, With[{m=primeMS[n]}, And[SameQ@@leafcount/@m, And@@balQ/@m]]];
Select[Range[nn], balQ]
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, Aug 23 2017
STATUS
approved