OFFSET
1,2
COMMENTS
Note that we recurse on the exponent + 1 for all other primes except the largest one in the factorization. Thus for 6 = 3^1 * 2^1 we construct a tree by joining trees 1 and 2 with a new root node, for 7 = 7^1 * 5^0 * 3^0 * 2^0 we join four 1-trees (single leaves) with a new root node, for 8 = 2^3 we add a single edge below tree 3 and for 9 = 3^2 * 2^0 we join trees 2 and 1, to get the mirror image of tree 6. Compare to Matula/Goebel numbering of (unoriented) rooted trees as explained in A061773.
LINKS
A. Karttunen, Alternative Catalan Orderings (with the complete Scheme source)
A. Karttunen, Complete Scheme-program for computing this sequence.
FORMULA
EXAMPLE
The rooted plane trees encoded here are:
.....................o...............o.........o...o..o.......
.....................|...............|..........\./...|.......
.......o....o...o....o....o.o.o..o...o.o.o.o.o...o....o...o...
.......|.....\./.....|.....\|/....\./...\|.|/....|.....\./....
*......*......*......*......*......*......*......*......*.....
1......2......3......4......5......6......7......8......9.....
PROG
(Scheme functions showing the essential idea. For the complete source, follow the "Alternative Catalan Orderings" link:)
(define (primefactorization->parenthesization n) (map primefactorization->parenthesization (explist->Nvector! (primefactorization->explist n))))
Function primefactorization->explist maps 1 to (), 2 to (1), 3 to (1 0), 4 to (2), 12 to (1 2), etc.
(define (explist->Nvector! el) (cond ((pair? el) (let loop ((el (cdr el))) (cond ((pair? el) (set-car! el (1+ (car el))) (loop (cdr el))))))) el)
CROSSREFS
KEYWORD
nonn,nice,base
AUTHOR
Antti Karttunen, Sep 13 2002
STATUS
approved