For prime p, the factorization tree is a single vertex in just one way so that a(p) = 1.
For composite n, the two subtrees at n are a split of n into two factors n = d * (n/d), without order, so that
$$ a(n) \ = \sum_{\substack{d\, |\, n \\ 2\, \le \, d \, \le \, n/d}} a(d)\, a\left(\frac{n}{d}\right). $$
a(1) = 1 is by convention, reckoning 1 as having a single empty factorization.
Examples: For n = 12 and n = 16, there are 2 factor trees:
12 12
/ \ / \
2 6 3 4
/ \ / \
2 3 2 2
16 16
/ \ / \
2 8 4 4
/ \ / \ / \
2 4 2 2 2 2
/ \
2 2
For n = 12 (above), the tree structures are the same but the values are not the same and are therefore distinct factorization trees.
The same goes for n = 30 leading to 3 binary unordered tree-factorizations:
30 30 30
/ \ / \ / \
2 15 3 10 5 6
/ \ / \ / \
3 5 2 5 2 3
Test cases:
1 | 2 | 12 | 16 | 30 | 144 | 900 | 9000 |
---|---|---|---|---|---|---|---|
1 | 1 | 2 | 2 | 3 | 42 | 171 | 3166 |
Summary:
Input: A positive integer n.
Output: a(n), the number of complete binary unordered tree-factorizations of n.
Optional: To simplify things the case n = 1 can be ignored.
Credits: The idea is from an unpublished OEIS sequence yet under consideration.
This is code-golf, so each language's shortest code in bytes wins.
\$
on both sides (note the backslash.) \$\endgroup\$a(144)
, which is41
to my calculation, but42
with your formula. tio \$\endgroup\$