\\ Kevin Ryde, April 2024 \\ \\ This is some PARI/GP code to calculate an individual term of either \\ \\ A206493(n) = product of vertex subtree sizes, \\ A206494(n) = number of "upwards" orderings of vertices, \\ so each parent somewhere after all its children. \\ in the rooted tree with Matula-Goebel number n. \\ default(recover,0) default(strictargs,1) \\ MG_size_and_product_of_sizes() returns a 2 element vector [size,product], \\ size = A061775(n) = number of vertices in tree n \\ product = A206493(n) = product of subtree sizes in tree n \\ MG_size_and_product_of_sizes(n) = { \\ primepi(f[i,1]) is each child subtree under the root of n. \\ f[i,2] is the number of repetitions of that subtree. my(f=factor(n), size=1); for(i=1,#f[,1], my(s); [s,f[i,1]] = MG_size_and_product_of_sizes(primepi(f[i,1])); size += s*f[i,2]); [size, size*factorback(f)]; } A206493_MG_subtree_sizes_product(n) = \ MG_size_and_product_of_sizes(n)[2]; A206494_MG_num_upward_orderings(n) = \ my(s,p); [s,p]=MG_size_and_product_of_sizes(n); s!/p; { print1("A206493 sizes product = "); for(n=1,20, print1(A206493_MG_subtree_sizes_product(n)",")); print("..."); print1("A206494 num upwards = "); for(n=1,20, print1(A206494_MG_num_upward_orderings(n)",")); print("..."); } \\----------------------------------------------------------------------------- \\ Notes \\ ----- \\ \\ MG_size_and_product_of_sizes() is recursive but maximum recursion \\ depth is small, as usual for Matula-Goebel tree numbers, since \\ any n small enough for primepi(n) has only small tree height. \\ \\ Each exponent from factor() is the number of repetitions of the \\ corresponding child subtree. This becomes exponent for the \\ "product" (factorback()), and multiplier for the "size". \\ There's no attempt to notice repeats of subtrees in different \\ parts of the tree since large repeated subtrees are unlikely. \\ \\ \\ A206494_MG_num_upward_orderings() uses the sequence formula \\ and calculates s!/p just with full s! and then divide. \\ This is reckoned enough since any large s! is large final \\ result anyway. \\ \\ Large s only occurs when the root has a large number of small \\ child subtrees, since primepi(c) is limited to small c. \\ In that case, p is a product of small sizes and s! is much bigger. \\----------------------------------------------------------------------------- print("end");