W

 Will Nicholes

Binary-encoded Prime Signatures

Prime signatures are a way of describing the prime factorization of a number. For example, the number 28's prime factorization is 22 × 7, which can be abstracted to p2q (where p and q are distinct primes) or p02p1 (where p0 and p1 are distinct primes.)

The prime signature lists the exponents of the prime factors, sorted from smallest exponent to greatest. Using 28 as an example, its prime prime signature is {1,2}. All prime numbers have a prime signature of {1}, squares of primes have prime signatures of {2}, a number composed of two primes has a prime signature of {1,1}, etc.

Another way of expressing the prime factorization would be in to encode it as binary, where each binary digit represents an element of the prime factorization. In order to do this, we need to assign each binary "column" to an element (such as p, p2, q, etc.).

Let's start with the number 1: it might seem as though its prime signature would be {0} or {}, meaning no primes at all; however, by definition, the prime signature of 1 is {1}. The prime signatures of 2 and 3 are also {1} since each is a prime; 4 has a prime signature of {2}, since it's a square of a prime.

We can therefore assign the rightmost binary column to p, where p represents a unique prime, and the second (from the right) binary column to p2, which represents the square of the prime. Let's take a look:

NumberPrime factorizationPrime signaturep2 p
111{1}0 1
22p{1}0 1
33p{1}0 1
42 × 2p2{2}1 0

 

The next new prime signature we encounter is {1,1} for 6. 6's prime factorization is of the form pq, so we need a column for q as well:

NumberPrime factorizationPrime signatureq p2 p
55p{1}0 0 1
62 × 3pq{1,1}1 0 1

 

Continuing on, we see 7 (prime signature of {1}) then 8 (prime signature of {3}). We don't need a new column for p3, though: since we already have p2 and p, we can just put a "1" in each of those columns to indicate a p3.

NumberPrime factorizationPrime signatureq p2 p
77p{1}1 0 1
82 × 2 × 2p2{3}0 1 1

 

In fact, the only new columns we'll ever need to add are of the form px2n, where px is a unique prime (p, q, etc.) and n is a non-negative integer. So now that we know all the columns we'll ever need to add, the question becomes: in what order shall we add them?

Skipping through the numbers whose prime signatures we've already seen, we find that the next columns we'll need are p4 for 16, then r for 30, then q2 for 36.

NumberPrime factorizationPrime signature q2 r p4q p2 p
162 × 2 × 2 × 2p4{4}0 0 1 0 0 0
302 × 3 × 5pqr{1,1,1}0 1 0 1 0 1
362 × 2 × 3 × 3p2q2{2,2}1 0 0 0 1 0

 

The following table lists the first 48 binary columns needed, the number whose prime signature required the column be added, and its prime signature. For brevity, long prime signatures such as {1,1,1,1,1,1} are shown as 6{1}, meaning the prime signature consists of 6 ones.

ColumnLowest number requiring the columnNumber's prime signature
1p1 (or 2){1}
2p24{2}
3q6{1,1}
4p416{4}
5r30{1,1,1}
6q236{2,2}
7s210{1,1,1,1}
8p8256{8}
9r2900{2,2,2}
10q41,296{4,4}
11t2,310{1,1,1,1,1}
12u30,0306{1}
13s244,100{2,2,2,2}
14p1665,536{16}
15v510,5107{1}
16r4810,000{4,4,4}
17q81,679,616{8,8}
18t25,336,100{2,2,2,2,2}
19w9,699,6908{1}
20x223,092,8709{1}
21u2901,800,9006{2}
22s41,944,810,000{4,4,4,4}
23p324,294,967,296{32}
24y6,469,693,23010{1}
25z200,560,490,13011{1}
26v2260,620,460,1007{2}
27r8656,100,000,000{8,8,8}
28q162,821,109,907,456{16,16}
29a7,420,738,134,81012{1}
30t428,473,963,210,000{4,4,4,4,4}
31w294,083,986,096,1008{2}
32b3.04250264 × 101413{1}
33c1.30827613 × 101614{1}
34x24.97704286 × 10169{2}
35d6.14889783 × 101715{1}
36u48.13244863 × 10176{4}
37s83.78228594 × 1018{8,8,8,8}
38p641.84467441 × 1019{64}
39e3.25891585 × 101916{1}
40y24.18569305 × 101910{2}
41f1.92276035 × 102117{1}
42z24.02245102 × 102211{2}
43v46.79230242 × 10227{4}
44g1.17288381 × 102318{1}
45r164.30467210 × 1023{16,16,16}
46h7.85832155 × 102419{1}
47q327.95866111 × 1024{32,32}
48i5.50673545 × 102520{1}

 

With the exception of 1, all of the numbers in the above table happen to take the form m2n, where m is a primorial number (Wikipedia has an overview of primorials here), and n is a non-negative integer.

In the table below are the smallest integers that represent the first 53 unique prime signatures. Their prime signature is converted into a binary encoding, then the binary is converted to decimal. Thus each unique prime signature can be represented as a single integer.

NumberPrime factor-
ization
Prime signatureBinary Decimal
2p{1}11
4p2{2}102
6pq{1,1}1015
8p3{3}113
12p2q{1,2}1106
16p4{4}10008
24p3q{1,3}1117
30pqr{1,1,1}1010121
32p5{5}10019
36p2q2{2,2}10001034
48p4q{1,4}110012
60p2qr{1,1,2}1011022
64p6{6}101010
72p3q2{2,3}10001135
96p5q{1,5}110113
120p3qr{1,1,3}1011123
128p7{7}101111
144p4q2{2,4}10100040
180p2q2r{1,2,2}11001050
192p6q{1,6}111014
210pqrs{1,1,1,1}101010185
216p3q3{3,3}10011139
240p4qr{1,1,4}1110028
256p8{8}10000000128
288p5q2{2,5}10100141
360p3q2r{1,2,3}11001151
384p7q{1,7}111115
420p2qrs{1,1,1,2}101011086
432p4q3{3,4}10110044
480p5qr{1,1,5}1110129
512p9{9}10000001129
576p6q2{2,6}10101042
720p4q2r{1,2,4}11100056
768p8q{1,8}10000100132
840p3qrs{1,1,1,3}101011187
864p5q3{3,5}10110145
900p2q2r2{2,2,2}100100010290
960p6qr{1,1,6}1111030
1024p10{10}10000010130
1080p3p3r{1,3,3}11011155
1152p7q2{2,7}10101143
1260p2q2rs{1,1,2,2}1110010114
1296p4q4{4,4}1000001000520
1440p5q2r{1,2,5}11100157
1536p9q{1,9}10000101133
1680p4qrs{1,1,1,4}101110092
1728p6q3{3,6}10111046
1800p3q2r2{2,2,3}100100011291
1920p7qr{1,1,7}1111131
2048p11{11}10000011131
2160p4q3r{1,3,4}11110060
2304p8q2{2,8}10100000160
2310pqrst{1,1,1,1,1}100010101011109

 

From this we can see that each integer can be converted into another integer which represents its prime signature: 2 gives us 1, 6 gives us 5, etc. Here is a table of the first 30 integers converted in this manner:

NumberEncoded
10 (or 1*)
21
31
42
51
65
71
83
92
105
111
126
131
145
155
   
NumberEncoded
168
171
186
191
206
215
225
231
247
252
265
273
286
291
3021

 

*The number 1 is a special case; if we consider its prime signature to be {0} or {} (which would be consistent with the fact that it has no true prime factors), its binary-encoded prime signature would be 0; if we go by the definition of its prime signature as {1}, then its binary-encoded prime signature would be 1. To be consistent with the fact that all the other binary "columns" are created from numbers of the form m2n (where m is a primorial and n is a non-negative integer), for the purposes of binary encoding and decoding we will consider the prime signature of 1 to be {} and its binary-encoded prime signature representation to be 0.

Although we can convert any integer into another integer which represents its binary-encoded prime signature, we can't always perform the reverse operation. Some codes are invalid because they represent a "denormalized" prime signature. For example, decimal 4 (binary 100) corresponds to a prime signature of q. Since there is a q but no p in this representation, it would never be the result of a "forward" conversion. One could represent the result of an invalid reverse operation as a zero, however, since no valid prime signature would convert to 0 upon decoding.

Below is a table of the first few integers, and the numbers whose prime signatures they represent. The rightmost column shows the smallest number represented by the encoded prime signature, or 0 if the prime signature encoded is not valid.

NumberDecoded
011
12, 3, 5, 7...2
24, 9, 25, 49...4
38, 27, 125...8
4Invalid: q, but no p0
56, 10, 14, 15...6
612, 18, 20, 28...12
724, 40, 54, 56...24
816, 81...16
932, 243...32
1064, 729...64
11128, 2187...128
1248, 80, 112...48
1396, 486...96
14192, 1458...192
15384, 4374...384
16-20Invalid: r, but no q0
2130, 42, 70...30
2260, 84, 90...60
23120, 270...120
24-27Invalid: r, but no q0
28240, 810...240
29480, 2430...480
30960, 7290...960
311920, 21870...1920
32-33Invalid: q2, but no p20
3436, 100...36
3572, 108...72
36-38Invalid: q3, but no p30
39216, 1000...216
40144, 324...144

 

Repeatedly "encoding" or "decoding" a number gives us some interesting results. Since zero does not have a valid prime signature, further "encode"s cannot be performed once a zero appears. Since a 0 is the result when a 1 is encoded, and a 1 is a result when a prime number is encoded, most small integers quickly hit a "dead-end":

Starting numberResulting "encode" sequence
11, 0
22, 1, 0
33, 1, 0
44, 2, 1, 0
66, 5, 1, 0
77, 1, 0
88, 3, 1, 0
99, 2, 1, 0
1010, 5, 1, 0

 

More investigation is needed to see if any numbers don't hit this dead-end (for example, if they enter a repeating loop.)

The following table shows what happens when we repeatedly "decode" a number. Here we assume that decoding a number gives us the smallest number whose prime signature matches what's encoded, or zero if the encoding is invalid as explained above.

Starting numberResulting "decode" sequence
00, 1, 2, 4, 0...
33, 8, 16, 0...
55, 6, 12, 48, 0...
77, 24, 0...
99, 32, 0...
1010, 64, 0...
1111, 128, 256, 0...
1313, 96, 0...
1414, 192, 0...
1515, 384, 0...

 

Here, upon repeated "decoding", an invalid prime signature is quickly found, and the sequence enters a loop: 0, 1, 2, 4, 0, 1, 2, 4, 0... More investigation is needed here also to determine whether there are other loops that might appear, or perhaps even an endless, non-looping sequence. The latter seems unlikely, since the likelihood that a number will be an invalid prime signature representative increases the larger it is.

 
|
Weblog Commenting and Trackback by HaloScan.com 
Validate this page