Friday, December 01, 2006

The Prime Game

First, the game.

Ask a friend to write down a prime number. Bet them that you can always strike out 0 or more digits to get one of the following 26 primes:

2, 3, 5, 7, 11, 19, 41, 61, 89, 409, 449, 499, 881, 991, 6469, 6949, 9001, 9049, 9649, 9949, 60649, 666649, 946669, 60000049, 66000049, 66600049.

For example, if your friend writes down 43, you can strike out the 4 to get 3. If your friend writes down 946969, you can strike out the first 9 and the 6's to get 499.

(There's not always a unique way to do this, and of course it works with some non-primes, too: if your friend writes down 35, which isn't a prime, you can strike out the 3 to get 5 or vice versa. But if someone gives you a number where you can't strike out some subset of the digits to get a prime on the list above, then that number isn't prime. For example, you can't strike out any subset of the digits of 649 to get a prime on the list, but 649 isn't prime.)

I published this strange result in the Journal of Recreational Mathematics in 2000; there's a copy on my papers page. Believe it or not, there's actually some interesting mathematics behind it.

Let's say that a string of symbols x is a subsequence of a string of symbols y if you can strike out some symbols of y (not necessarily contiguous) to get x. ("Subsequence" seems to be the preferred term in North America, but in Europe they call this a "subword". However "subword" is used in North America to mean "contiguous subblock".) The relation "x is a subsequence of y" is a partial order, meaning it shares the following properties of the ordinary <= relation on integers:

  • x is a subsequence of x;

  • If x is a subsequence of y and y is a subsequence of x, then x=y.

  • If x is a subsequence of y and y is a subsequence of z, then x is a subsequence of z.

We now call two strings comparable if x is a subsequence of y, or vice versa; otherwise, we say x and y are incomparable. A set is pairwise incomparable if every pair of elements is incomparable.

Now, a very neat result about the subsequence partial order is that every pairwise incomparable set is finite. This isn't obvious, and it isn't true for every partial order. (For example, it isn't true for the order where "subsequence" is replaced by "subword".) You may enjoy trying to prove this.

We need one more concept: the minimal element. A string x in S is said to be minimal for S if whenever y in S is a subsequence of x, then y=x. Given a set of strings S, it's not hard to see that the set of minimal elements of S is pairwise incomparable. So it must be finite. And every string in S has the property that some minimal element is a subsequence of it.

Now, to get the prime game, let S be the set of strings representing primes in base 10. The list of 26 primes above is the set of minimal elements for S.

Determining the set of minimal elements isn't always easy. For example, if instead of the primes we use the decimal representations of the powers of 2, then no one currently knows how to compute the set of minimal elements. It's probably {1,2,4,8,65536}, but proving this seems quite hard.

A neat consequence of this result is that, given any language L, the set of all subsequences of strings in L is regular. We can't always easily determine the regular expression or automaton for L, but we know it exists.

Here's a link to a file of cards you can print, cut out, and perhaps laminate, with the prime game on them. Enjoy.

15 comments:

Anonymous said...

This is, indeed, very neat!

Anonymous said...

Jeff,

Very cool!

Deane

Anonymous said...

So is there an algorithm that takes as input a base and outputs the list of minimal primes in that base? Or did you just get lucky with decimals that you were able to construct the complete description?

Jeffrey Shallit said...

Hi, David. Thanks for stopping by.

The primes are sufficiently dense that there might well be an algorithm to deduce the minimal set in any base of representation. But I don't currently have such an algorithm.

Someone has suggested the size of the minimal set, as a function of the base, as a measure of the complexity of the original language, but as far as I know, little work has been done on this because computing the minimal set is, in general, so hard.

Anonymous said...

Hi Jeff (and all),

If anyone is planning on coming up with a recursive method of calculating such minimal sets, perhaps I can get people started with a base case:

unary: {11}

(I know recusion is not a likely candidate for such an algorithm, but then the tongue-in-cheekiness doesn't work).

Anonymous said...

Jeff, that's something new I learn from your blog today. Very cool indeed! :)

Anonymous said...

Is the minimal set for the squares known? My Haskell code has so far found:
1,4,9,25,36,576,676,7056,80656,
665856,2027776,2802276,22282727076,
77770707876,78807087076,
7888885568656,8782782707776,
72822772707876,555006880085056,
782280288087076,827702888070276,
888288787822276,2282820800707876,
7880082008070276
It looks like it could go on and on.

Jeffrey Shallit said...

No, the minimal set for squares in base 10 is not known, to my knowledge. It might be extremely difficult.

Anonymous said...

I'd include 0 as a square, which would simplify the minimal set of the squares in base 10 somewhat. :)

Bassam Abdul-Baki said...

Hi Jeffrey,

Thanks for a very interesting article. Looking at the powers of 2 minimal set, I think there's a way to determine it, which I've somewhat started in an Excel spreadsheet. I'll let you know if do.

Anonymous said...
This comment has been removed by a blog administrator.
Unknown said...

I found the minimal set of primes with >=2 digits, the set is {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 227, 251, 257, 277, 281, 349, 409, 449, 499, 521, 557, 577, 587, 727, 757, 787, 821, 827, 857, 877, 881, 887, 991, 2087, 2221, 5051, 5081, 5501, 5581, 5801, 5851, 6469, 6949, 8501, 9001, 9049, 9221, 9551, 9649, 9851, 9949, 20021, 20201, 50207, 60649, 80051, 666649, 946669, 5200007, 22000001, 60000049, 66000049, 66600049, 80555551, 555555555551, 5000000000000000000000000000027}

Also, I solved this set in bases 2, 3, 4, 5, 6, 8, 10, 12: (if the base is prime, the prime "10" (i.e. the prime equal to the base) is also excluded, i.e. my set is the minimal set of primes > base, rather than >= base)

Base 2: {11}

Base 3: {12, 21, 111}

Base 4: {11, 13, 23, 31, 221}

Base 5: {12, 21, 23, 32, 34, 43, 104, 111, 131, 133, 313, 401, 414, 3101, 10103, 14444, 30301, 33001, 33331, 44441, 300031, 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013}

Base 6: {11, 15, 21, 25, 31, 35, 45, 51, 4401, 4441, 40041}

Base 8: {13, 15, 21, 23, 27, 35, 37, 45, 51, 53, 57, 65, 73, 75, 107, 111, 117, 141, 147, 161, 177, 225, 255, 301, 343, 361, 401, 407, 417, 431, 433, 463, 467, 471, 631, 643, 661, 667, 701, 711, 717, 747, 767, 3331, 3411, 4043, 4443, 4611, 5205, 6007, 6101, 6441, 6477, 6707, 6777, 7461, 7641, 47777, 60171, 60411, 60741, 444641, 500025, 505525, 3344441, 4444477, 5500525, 5550525, 55555025, 444444441, 744444441, 77774444441, 7777777777771, 555555555555525, 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447}

Base 10: {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 227, 251, 257, 277, 281, 349, 409, 449, 499, 521, 557, 577, 587, 727, 757, 787, 821, 827, 857, 877, 881, 887, 991, 2087, 2221, 5051, 5081, 5501, 5581, 5801, 5851, 6469, 6949, 8501, 9001, 9049, 9221, 9551, 9649, 9851, 9949, 20021, 20201, 50207, 60649, 80051, 666649, 946669, 5200007, 22000001, 60000049, 66000049, 66600049, 80555551, 555555555551, 5000000000000000000000000000027}

Base 12: {11, 15, 17, 1B, 25, 27, 31, 35, 37, 3B, 45, 4B, 51, 57, 5B, 61, 67, 6B, 75, 81, 85, 87, 8B, 91, 95, A7, AB, B5, B7, 221, 241, 2A1, 2B1, 2BB, 401, 421, 447, 471, 497, 565, 655, 665, 701, 70B, 721, 747, 771, 77B, 797, 7A1, 7BB, 907, 90B, 9BB, A41, B21, B2B, 2001, 200B, 202B, 222B, 229B, 292B, 299B, 4441, 4707, 4777, 6A05, 6AA5, 729B, 7441, 7B41, 929B, 9777, 992B, 9947, 997B, 9997, A0A1, A201, A605, A6A5, AA65, B001, B0B1, BB01, BB41, 600A5, 7999B, 9999B, AAAA1, B04A1, B0B9B, BAA01, BAAA1, BB09B, BBBB1, 44AAA1, A00065, BBBAA1, AAA0001, B00099B, AA000001, BBBBBB99B, B0000000000000000000000000009B, 400000000000000000000000000000000000000077}

Unknown said...

I found the minimal set of primes with >=2 digits, the set is {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 227, 251, 257, 277, 281, 349, 409, 449, 499, 521, 557, 577, 587, 727, 757, 787, 821, 827, 857, 877, 881, 887, 991, 2087, 2221, 5051, 5081, 5501, 5581, 5801, 5851, 6469, 6949, 8501, 9001, 9049, 9221, 9551, 9649, 9851, 9949, 20021, 20201, 50207, 60649, 80051, 666649, 946669, 5200007, 22000001, 60000049, 66000049, 66600049, 80555551, 555555555551, 5000000000000000000000000000027}

Also, I solved this set in bases 2, 3, 4, 5, 6, 8, 10, 12: (if the base is prime, the prime "10" (i.e. the prime equal to the base) is also excluded, i.e. my set is the minimal set of primes > base, rather than >= base)

Base 2: {11}

Base 3: {12, 21, 111}

Base 4: {11, 13, 23, 31, 221}

Base 5: {12, 21, 23, 32, 34, 43, 104, 111, 131, 133, 313, 401, 414, 3101, 10103, 14444, 30301, 33001, 33331, 44441, 300031, 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013}

Base 6: {11, 15, 21, 25, 31, 35, 45, 51, 4401, 4441, 40041}

Base 8: {13, 15, 21, 23, 27, 35, 37, 45, 51, 53, 57, 65, 73, 75, 107, 111, 117, 141, 147, 161, 177, 225, 255, 301, 343, 361, 401, 407, 417, 431, 433, 463, 467, 471, 631, 643, 661, 667, 701, 711, 717, 747, 767, 3331, 3411, 4043, 4443, 4611, 5205, 6007, 6101, 6441, 6477, 6707, 6777, 7461, 7641, 47777, 60171, 60411, 60741, 444641, 500025, 505525, 3344441, 4444477, 5500525, 5550525, 55555025, 444444441, 744444441, 77774444441, 7777777777771, 555555555555525, 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447}

Base 10: {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 227, 251, 257, 277, 281, 349, 409, 449, 499, 521, 557, 577, 587, 727, 757, 787, 821, 827, 857, 877, 881, 887, 991, 2087, 2221, 5051, 5081, 5501, 5581, 5801, 5851, 6469, 6949, 8501, 9001, 9049, 9221, 9551, 9649, 9851, 9949, 20021, 20201, 50207, 60649, 80051, 666649, 946669, 5200007, 22000001, 60000049, 66000049, 66600049, 80555551, 555555555551, 5000000000000000000000000000027}

Base 12: {11, 15, 17, 1B, 25, 27, 31, 35, 37, 3B, 45, 4B, 51, 57, 5B, 61, 67, 6B, 75, 81, 85, 87, 8B, 91, 95, A7, AB, B5, B7, 221, 241, 2A1, 2B1, 2BB, 401, 421, 447, 471, 497, 565, 655, 665, 701, 70B, 721, 747, 771, 77B, 797, 7A1, 7BB, 907, 90B, 9BB, A41, B21, B2B, 2001, 200B, 202B, 222B, 229B, 292B, 299B, 4441, 4707, 4777, 6A05, 6AA5, 729B, 7441, 7B41, 929B, 9777, 992B, 9947, 997B, 9997, A0A1, A201, A605, A6A5, AA65, B001, B0B1, BB01, BB41, 600A5, 7999B, 9999B, AAAA1, B04A1, B0B9B, BAA01, BAAA1, BB09B, BBBB1, 44AAA1, A00065, BBBAA1, AAA0001, B00099B, AA000001, BBBBBB99B, B0000000000000000000000000009B, 400000000000000000000000000000000000000077}

Unknown said...

I found the minimal set of primes with >=2 digits, the set is {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 227, 251, 257, 277, 281, 349, 409, 449, 499, 521, 557, 577, 587, 727, 757, 787, 821, 827, 857, 877, 881, 887, 991, 2087, 2221, 5051, 5081, 5501, 5581, 5801, 5851, 6469, 6949, 8501, 9001, 9049, 9221, 9551, 9649, 9851, 9949, 20021, 20201, 50207, 60649, 80051, 666649, 946669, 5200007, 22000001, 60000049, 66000049, 66600049, 80555551, 555555555551, 5000000000000000000000000000027}

Also, I solved this set in bases 2, 3, 4, 5, 6, 8, 10, 12: (if the base is prime, the prime "10" (i.e. the prime equal to the base) is also excluded, i.e. my set is the minimal set of primes > base, rather than >= base)

Base 2: {11}

Base 3: {12, 21, 111}

Base 4: {11, 13, 23, 31, 221}

Base 5: {12, 21, 23, 32, 34, 43, 104, 111, 131, 133, 313, 401, 414, 3101, 10103, 14444, 30301, 33001, 33331, 44441, 300031, 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013}

Base 6: {11, 15, 21, 25, 31, 35, 45, 51, 4401, 4441, 40041}

Base 8: {13, 15, 21, 23, 27, 35, 37, 45, 51, 53, 57, 65, 73, 75, 107, 111, 117, 141, 147, 161, 177, 225, 255, 301, 343, 361, 401, 407, 417, 431, 433, 463, 467, 471, 631, 643, 661, 667, 701, 711, 717, 747, 767, 3331, 3411, 4043, 4443, 4611, 5205, 6007, 6101, 6441, 6477, 6707, 6777, 7461, 7641, 47777, 60171, 60411, 60741, 444641, 500025, 505525, 3344441, 4444477, 5500525, 5550525, 55555025, 444444441, 744444441, 77774444441, 7777777777771, 555555555555525, 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447}

Base 10: {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 227, 251, 257, 277, 281, 349, 409, 449, 499, 521, 557, 577, 587, 727, 757, 787, 821, 827, 857, 877, 881, 887, 991, 2087, 2221, 5051, 5081, 5501, 5581, 5801, 5851, 6469, 6949, 8501, 9001, 9049, 9221, 9551, 9649, 9851, 9949, 20021, 20201, 50207, 60649, 80051, 666649, 946669, 5200007, 22000001, 60000049, 66000049, 66600049, 80555551, 555555555551, 5000000000000000000000000000027}

Base 12: {11, 15, 17, 1B, 25, 27, 31, 35, 37, 3B, 45, 4B, 51, 57, 5B, 61, 67, 6B, 75, 81, 85, 87, 8B, 91, 95, A7, AB, B5, B7, 221, 241, 2A1, 2B1, 2BB, 401, 421, 447, 471, 497, 565, 655, 665, 701, 70B, 721, 747, 771, 77B, 797, 7A1, 7BB, 907, 90B, 9BB, A41, B21, B2B, 2001, 200B, 202B, 222B, 229B, 292B, 299B, 4441, 4707, 4777, 6A05, 6AA5, 729B, 7441, 7B41, 929B, 9777, 992B, 9947, 997B, 9997, A0A1, A201, A605, A6A5, AA65, B001, B0B1, BB01, BB41, 600A5, 7999B, 9999B, AAAA1, B04A1, B0B9B, BAA01, BAAA1, BB09B, BBBB1, 44AAA1, A00065, BBBAA1, AAA0001, B00099B, AA000001, BBBBBB99B, B0000000000000000000000000009B, 400000000000000000000000000000000000000077}

Unknown said...

For minimal set of primes >b in base b, I only solved bases 2, 3, 4, 5, 6, 8, 10, 12, other bases seems to be very hard, e.g. For base 7, the set is {14, 16, 23, 25, 32, 41, 43, 52, 56, 61, 65, 113, 115, 131, 133, 155, 212, 221, 304, 313, 335, 344, 346, 364, 445, 515, 533, 535, 544, 551, 553, 1022, 1051, 1112, 1202, 1211, 1222, 2111, 3031, 3055, 3334, 3503, 3505, 3545, 4504, 4555, 5011, 5455, 5545, 5554, 6034, 6634, 11111, 11201, 30011, 30101, 31001, 31111, 33001, 33311, 35555, 40054, 100121, 150001, 300053, 351101, 531101, 1100021, 33333301, 5100000001, ..., 33333333333333331, ...}, and for base 9, the set is {12, 14, 18, 21, 25, 32, 34, 41, 45, 47, 52, 58, 65, 67, 74, 78, 81, 87, 117, 131, 135, 151, 155, 175, 177, 238, 272, 308, 315, 331, 337, 355, 371, 375, 377, 438, 504, 515, 517, 531, 537, 557, 564, 601, 638, 661, 702, 711, 722, 735, 737, 751, 755, 757, 771, 805, 838, 1011, 1015, 1101, 1701, 2027, 2207, 3017, 3057, 3101, 3501, 3561, 3611, 3688, 3868, 5035, 5051, 5071, 5101, 5501, 5554, 5705, 5707, 7017, 7075, 7105, 7301, 8535, 8544, 8555, 8854, 20777, 22227, 22777, 30161, 33388, 50161, 50611, 53335, 55111, 55535, 55551, 57061, 57775, 70631, 71007, 77207, 100037, 100071, 100761, 105007, 270707, 301111, 305111, 333035, 333385, 333835, 338885, 350007, 500075, 530005, 555611, 631111, 720707, 2770007, 3030335, 7776662, 30300005, 30333335, 38333335, 51116111, 70000361, 300030005, 300033305, 351111111, 1300000007, 5161111111, 8333333335, ..., 300000000035, ..., 544444444444, ..., 2000000000007, ..., 5700000000001, …, 30000000000000000000051, …, 56111111111111111111111111111111111111, ..., 7666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666662, …, 30_{1158}11, ...}

b number of minimal primes (start with b+1) base b base-b form of largest minimal prime (start with b+1) base b length of largest minimal prime (start with b+1) base b algebraic ((a×bn+c)/d) form of largest minimal prime (start with b+1) base b
2 1 11 2 3
3 3 111 3 13
4 5 221 3 41
5 22 10_{93}13 96 5^95+8
6 11 40041 5 5209
7 ≥71 ≥3_{16}1 ≥17 ≥(7^17−5)/2
8 75 4_{220}7 221 (4×8^221+17)/7
9 ≥142 ≥30_{1158}11 ≥1161 ≥3×9^1160+10
10 77 50_{28}27 31 5×10^30+27
11 ≥890 ≥5_{161}2A ≥163 ≥(11^163−57)/2
12 106 40_{39}77 42 4×12^41+91
13 ≥2451 ≥80_{32017}111 ≥32021 ≥8×13^32020+183
14 ≥594 ≥4D_{19698} ≥19699 ≥5×14^19698−1
15 ≥1146 ≥96_{104}08 ≥107 ≥(66×15^106−619)/7
16 ≥1873 ≥DB_{32234} ≥32235 ≥(206×16^32234−11)/15

Base 11 is very hard, since for the family 57* (i.e. 5777...777), I searched through 25000 digits without found any primes or probable primes (the family 57* in base 11 does not ruled out as only contain composite numbers), see the pdf file https://mersenneforum.org/attachment.php?attachmentid=24177&d=1610562701