How to list the prime factorised natural numbers?

278 Views Asked by At

Today I set out to invent a two character numeral system designed to make factorization trivial. Indeed, it lets one factor non-trivial numbers with over thousand digits within 30 seconds per hand - the upshot is that the notation isn't particularly suited for arithmetic. In fact, when I try to add certain two digit numbers, my computer gives me an overflow warning.

The idea is to not use any base like binary or decimal, as in $28=2\cdot 10^1+8\cdot 10^0$, but to hardcode the prime factors $28=2^2\cdot 3^0 \cdot 5^0 \cdot 7^1$ into the notation. So denote the start and end of a number by "$s$" and "$e$". I set

$0:=se$

and declare a natural number to be any string of the form "$sxe$" where $x$ is a finite string of numbers. The $n$'th number in the sequence $x$ denotes the power oth the $n$'th prime number and "$sxe$" is the associated product. So from an ordinal point of view

$1=2^0=s0e=ssee$

$2=2^1=s1e=ssseee$

$3=2^0\cdot 3^1=s01e=ssesseee$

$4=2^2=s2e=sssseeee$

$5=2^0\cdot 3^0\cdot 5^1=s001e=ssesesseee$

...

$28=2^2\cdot 3^0 \cdot 5^0 \cdot 7^1=s2001e=sssseeesesesseee$

I came to the conclusion that the language consists of all the strings with equal number of $s$'s and $e$'s, where while scanning from the left there are always more $s$'s than $e$'s and the substring $esee$ isn't allowed. The first condition makes sure that all numbers close and the second one disallows superfluous factor of powers of 0.

I've written a script which brute force generates these strings (it forms all permutations of even numbers of $s$'s and $e$'s and then drops the disallowed ones) and also one to translate them to decimal expression (which relies on knowing what the $n$'th prime is):

http://pastebin.com/RwkGX6TV

This e.g tells me that 2417851639229258349412352 is sssesssseeeeee and the nice thing is that all numbers factor easily:

$sssesssseeeeee$

$= s(s(se)(s(s(s(se)e)e)e)e)e$

$=s(s0(s(s(s0e)e)e)e)e$

$=s(s0(s(s1e)e)e)e$

$=s(s0(s2e)e)e$

$=s(s0(2^2)e)e$

$=s(2^0\cdot 3^{2^2})e$

$=2^{3^{2^2}}.$

For now, I've generated most of the numbers with 20 characters and I've added an artificial bound of $R=10^{50}$ to the size of the exponents. This is necessary, as e.g. the number $13$, being the $6$th prime, reads $ssesesesesesseee$, i.e. $s000001e$ but it's neighbors in this enumeration can be numbers with thousands of digits. Generating the strings is simple down at $14$ but multiplication is hard. Later, also higher number of strings are needed and the way I produce the permutation is probably inefficient.

To generate a bigger library of numbers, I'd like to know if someone has an idea for a less arbitrary enumeration of the the strings which avoid the uncomputably big numbers.

Does someone maybe know an good way to enumerate the numbers in the form $1,2,3,2^2,5,2\cdot 3,7,\cdots,3^{2^5}\cdot 11^2\cdot 19^3,\cdots$?