I need to implement a RegexMathEngine optimization that treats (?!p)q as (?=q)(?!p)q for expressions where it can know q will evaluate faster. But I've got to figure out how to show it in the debug trace.
Thanks :) I would really like to replace it with another answer that requires that virtualized-remainder-math trick, and I think your perfect powers problem would do nicely as a question that isn't just specialized to regexes. The numbers need a name though :) something referring to the perfect power hierarchy they contain.