Friday, June 16

Asterisks and circumflexes

Given a positive integer, output all possible valid prime-factorization "statements" thereof created by inserting into its digit sequence zero or more multiplication (*) symbols and zero or more power (^) symbols. In order for a prime-factorization statement to be valid, it must be the product of powers of (left to right) strictly increasing primes. A single prime (with or without an exponent) is acceptable. No prime and no exponent may begin with a zero. No exponent may be equal to one. For instance, given 23537373797, here is the output (each <#> is how many digits there would be in the statement's decimal expansion):