While helping a friend with a job interview and solving some optimization problems, I stumbled upon a really cool little recurrence that predicts the exponents of multiples of a prime. The problem that led to it can be read here and here.
The recurrence itself is this:
So, for example, if we want to find the exponents of two for the factorization of the first eight multiples of two:
ε(2, 0) = (1)
ε(2, 1) = (1, 1 + 1) = (1, 2)
ε(2, 2) = (1, 2, 1, 2 + 1) = (1, 2, 1, 3)
ε(2, 3) = (1, 2, 1, 3, 1, 2, 1, 3 + 1) = (1, 2, 1, 3, 1, 2, 1, 4)
Which predicts the following factorizations:
2 = 2^1
4 = 2^2
6 = 2^1 * 3^1
8 = 2^3
10 = 2^1 * 5^1
12 = 2^2 * 3^1
14 = 2^1 * 7^1
16 = 2^4
In a compressed form, these are the exponents until 6 for 2, 3, 5 and 7:
12131214121312151213121412131216
112112113112112113112112114112112113112112113112112114112112113112112113112112115112112113112112113112112114112112113112112113112112114112112113112112113112112115112112113112112113112112114112112113112112113112112114112112113112112113112112116
11112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211114111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111141111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111411112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211114111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111151111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111411112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211114111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111141111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111411112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211115111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111141111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111411112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211114111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111141111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111511112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211114111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111141111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111411112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211114111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111151111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111411112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211114111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111141111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211113111121111211112111121111411112111121111211112111131111211112111121111211113111121111211112111121111311112111121111211112111131111211112111121111211116
1111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111115111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111511111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111151111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111115111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111511111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111151111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111114111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111411111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111141111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111113111111211111121111112111111211111121111112111111311111121111112111111211111121111112111111211111131111112111111211111121111112111111211111121111116