I've been reviewing the distribution of ending digits of prime numbers expressed in base 10 and in other bases. For the purpose of this exercise, I used the first 304 prime numbers which begin with 2 and end with 2003. This list is at bottom of this post.
Starting with base 10 is a good starting point. Most people have seen that these primes only end with digits 1, 2, 3, 5, 7 and 9. After 5, 2 and 5 are no longer the ending digit of primes since even numbers greater than 2 are not prime and multiples of 5 all end in 5 or 0. Excluding 2 and 5, the distribution of ending digits of primes in from this list is as follows:
Ending Distribution
Digit
1 73
3 79
7 77
9 73
Tables of these first 304 primes expressed in bases 2 through 23 and the distribution of the prime number ending digits in these bases is available here.
Here is excerpt from the table showing the distribution for bases 2-10:
| | | Bases 2-10 distribution of ending digits (first 304 primes) | | | | | | |
Ending Digit | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
1 | 303 | 148 | 147 | 73 | 148 | 46 | 68 | 47 | 73 |
2 | 0 | 155 | 1 | 78 | 1 | 48 | 1 | 51 | 1 |
3 | 0 | 0 | 156 | 79 | 1 | 53 | 78 | 1 | 79 |
4 | 0 | 0 | 0 | 73 | 0 | 50 | 0 | 51 | 0 |
5 | 0 | 0 | 0 | 0 | 154 | 54 | 79 | 54 | 1 |
6 | 0 | 0 | 0 | 0 | 0 | 52 | 0 | 0 | 0 |
7 | 0 | 0 | 0 | 0 | 0 | 0 | 78 | 50 | 77 |
8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 0 |
9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 73 |
0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
Some observations from the above table:
In base 2, all primes end with a 1 except for 2 in base 2 which is 10 and it ends in 0. This makes sense because all primes greater than 2 are odd numbers and all odd numbers in base 2 end with the digit 1.
Notice that all primes over 3 in base 6 end in the digits 1 or 5. This can be explained by the fact that all primes over 3 are multiples of 6 minus 1 or plus 1 (for example 5 and 7). See these two other posts for more information on this prime number property:
A Prime Number Property Rediscovered
Prime Number Sandwich
Base 7 is also interesting in its distribution of ending digits in that it includes all possible digits 0 through 6. The prime 7 expressed in base 7 is 10; however, that is the last time in this base that a prime ends in 0 because any higher number in base 7 ending in 0 will be a multiple of 7 (such as 14 in base 7 is 20 and 49 in base 7 is 100) and therefore, is not prime. Also, the ending digits are fairly even distributed between the digits 1 through 6.
The distribution for base 7 prime ending digits begs the question of whether there are bases higher than 10 for which all possible ending digits are used. The attached spreadsheet has a tab for bases 11 through 23. The summary of ending digit distributions is (note - letters are used as digits to express numbers in bases higher than 10):
| | | | Bases 11 through 19 - Ending digit distribution (first 304 primes) | | | | | | | | | |
Ending digit | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
1 | 27 | 70 | 25 | 46 | 34 | 34 | 20 | 47 | 14 | 35 | 22 | 27 | 16 |
2 | 33 | 1 | 28 | 1 | 40 | 1 | 21 | 1 | 17 | 1 | 26 | 1 | 13 |
3 | 30 | 1 | 26 | 53 | 1 | 39 | 20 | 1 | 19 | 39 | 1 | 30 | 15 |
4 | 29 | 0 | 25 | 0 | 37 | 0 | 17 | 0 | 21 | 0 | 25 | 0 | 15 |
5 | 30 | 77 | 25 | 54 | 1 | 38 | 17 | 54 | 19 | 1 | 26 | 30 | 13 |
6 | 30 | 0 | 24 | 0 | 0 | 0 | 16 | 0 | 15 | 0 | 0 | 0 | 12 |
7 | 33 | 78 | 26 | 1 | 38 | 40 | 20 | 50 | 18 | 41 | 1 | 33 | 16 |
8 | 32 | 0 | 26 | 0 | 39 | 0 | 20 | 0 | 17 | 0 | 24 | 0 | 11 |
9 | 29 | 0 | 25 | 47 | 0 | 34 | 18 | 0 | 15 | 35 | 0 | 29 | 13 |
0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 |
A | 30 | 0 | 25 | 0 | 0 | 0 | 19 | 0 | 17 | 0 | 24 | 0 | 15 |
B | 0 | 77 | 24 | 50 | 39 | 39 | 20 | 50 | 19 | 38 | 25 | 1 | 14 |
C | 0 | 0 | 24 | 0 | 0 | 0 | 20 | 0 | 16 | 0 | 0 | 0 | 12 |
D | 0 | 0 | 0 | 52 | 39 | 41 | 19 | 51 | 19 | 40 | 26 | 32 | 11 |
E | 0 | 0 | 0 | 0 | 36 | 0 | 21 | 0 | 14 | 0 | 0 | 0 | 14 |
F | 0 | 0 | 0 | 0 | 0 | 38 | 19 | 0 | 14 | 0 | 0 | 29 | 15 |
G | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 0 | 15 | 0 | 22 | 0 | 14 |
H | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 16 | 36 | 28 | 30 | 15 |
I | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 18 | 0 | 0 | 0 | 14 |
J | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 38 | 28 | 32 | 15 |
K | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 26 | 0 | 13 |
L | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 30 | 16 |
It appears that when the base is a prime, that all possible digits are found as the ending digit of prime numbers expressed in these other bases. I say "appears" because this is a limited table (limited in number of primes and in bases) and can't be considered a proof. The table shows this for prime bases up to 23. Although not included in the table, I've also confirmed this for primes up to 31.
In a related topic, Dirichlet's theorem, states that for any two positive coprime integers a and d, there are infinitely many primes of the form a + nd, where n is also a positive integer. In other words, there are infinitely many primes that are congruent to a modulo d. I need to explore this theorem and the distribution of prime ending numbers to see how these concepts are linked.
This is another link discussing ending digits.
Numberphile has an interesting video about ending digits of prime numbers: (224) The Last Digit of Prime Numbers - Numberphile - YouTube
List of first 304 primes (2 through 2003) used for the distribution tables above:
2 |
3 |
5 |
7 |
11 |
13 |
17 |
19 |
23 |
29 |
31 |
37 |
41 |
43 |
47 |
53 |
59 |
61 |
67 |
71 |
73 |
79 |
83 |
89 |
97 |
101 |
103 |
107 |
109 |
113 |
127 |
131 |
137 |
139 |
149 |
151 |
157 |
163 |
167 |
173 |
179 |
181 |
191 |
193 |
197 |
199 |
211 |
223 |
227 |
229 |
233 |
239 |
241 |
251 |
257 |
263 |
269 |
271 |
277 |
281 |
283 |
293 |
307 |
311 |
313 |
317 |
331 |
337 |
347 |
349 |
353 |
359 |
367 |
373 |
379 |
383 |
389 |
397 |
401 |
409 |
419 |
421 |
431 |
433 |
439 |
443 |
449 |
457 |
461 |
463 |
467 |
479 |
487 |
491 |
499 |
503 |
509 |
521 |
523 |
541 |
547 |
557 |
563 |
569 |
571 |
577 |
587 |
593 |
599 |
601 |
607 |
613 |
617 |
619 |
631 |
641 |
643 |
647 |
653 |
659 |
661 |
673 |
677 |
683 |
691 |
701 |
709 |
719 |
727 |
733 |
739 |
743 |
751 |
757 |
761 |
769 |
773 |
787 |
797 |
809 |
811 |
821 |
823 |
827 |
829 |
839 |
853 |
857 |
859 |
863 |
877 |
881 |
883 |
887 |
907 |
911 |
919 |
929 |
937 |
941 |
947 |
953 |
967 |
971 |
977 |
983 |
991 |
997 |
1009 |
1013 |
1019 |
1021 |
1031 |
1033 |
1039 |
1049 |
1051 |
1061 |
1063 |
1069 |
1087 |
1091 |
1093 |
1097 |
1103 |
1109 |
1117 |
1123 |
1129 |
1151 |
1153 |
1163 |
1171 |
1181 |
1187 |
1193 |
1201 |
1213 |
1217 |
1223 |
1229 |
1231 |
1237 |
1249 |
1259 |
1277 |
1279 |
1283 |
1289 |
1291 |
1297 |
1301 |
1303 |
1307 |
1319 |
1321 |
1327 |
1361 |
1367 |
1373 |
1381 |
1399 |
1409 |
1423 |
1427 |
1429 |
1433 |
1439 |
1447 |
1451 |
1453 |
1459 |
1471 |
1481 |
1483 |
1487 |
1489 |
1493 |
1499 |
1511 |
1523 |
1531 |
1543 |
1549 |
1553 |
1559 |
1567 |
1571 |
1579 |
1583 |
1597 |
1601 |
1607 |
1609 |
1613 |
1619 |
1621 |
1627 |
1637 |
1657 |
1663 |
1667 |
1669 |
1693 |
1697 |
1699 |
1709 |
1721 |
1723 |
1733 |
1741 |
1747 |
1753 |
1759 |
1777 |
1783 |
1787 |
1789 |
1801 |
1811 |
1823 |
1831 |
1847 |
1861 |
1867 |
1871 |
1873 |
1877 |
1879 |
1889 |
1901 |
1907 |
1913 |
1931 |
1933 |
1949 |
1951 |
1973 |
1979 |
1987 |
1993 |
1997 |
1999 |
2003 |