Tree of Coprimes
Walk down the tree keeping the stack of ancestors; each node takes its nearest ancestor whose value is coprime with its own.
Walk down the tree keeping the stack of ancestors; each node takes its nearest ancestor whose value is coprime with its own.