Prime Numbers in Different Bases

Introduction

Prime numbers are prime numbers, even in different bases.

\\ PARI/GP
base = 9;
count = 0;
forprime (x=2, 1223, print1( fromdigits(digits(x, base)), “, ” ); count++;);
print(“\ncount = “, count);

Decimal (Base-10)

The first 200 prime numbers in decimal (base-10) are:

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

Binary (Base-2)

10, 11, 101, 111, 1011, 1101, 10001, 10011, 10111, 11101, 11111, 100101, 101001, 101011, 101111, 110101, 111011, 111101, 1000011, 1000111, 1001001, 1001111, 1010011, 1011001, 1100001, 1100101, 1100111, 1101011, 1101101, 1110001, 1111111, 10000011, 10001001, 10001011, 10010101, 10010111, 10011101, 10100011, 10100111, 10101101, 10110011, 10110101, 10111111, 11000001, 11000101, 11000111, 11010011, 11011111, 11100011, 11100101, 11101001, 11101111, 11110001, 11111011, 100000001, 100000111, 100001101, 100001111, 100010101, 100011001, 100011011, 100100101, 100110011, 100110111, 100111001, 100111101, 101001011, 101010001, 101011011, 101011101, 101100001, 101100111, 101101111, 101110101, 101111011, 101111111, 110000101, 110001101, 110010001, 110011001, 110100011, 110100101, 110101111, 110110001, 110110111, 110111011, 111000001, 111001001, 111001101, 111001111, 111010011, 111011111, 111100111, 111101011, 111110011, 111110111, 111111101, 1000001001, 1000001011, 1000011101, 1000100011, 1000101101, 1000110011, 1000111001, 1000111011, 1001000001, 1001001011, 1001010001, 1001010111, 1001011001, 1001011111, 1001100101, 1001101001, 1001101011, 1001110111, 1010000001, 1010000011, 1010000111, 1010001101, 1010010011, 1010010101, 1010100001, 1010100101, 1010101011, 1010110011, 1010111101, 1011000101, 1011001111, 1011010111, 1011011101, 1011100011, 1011100111, 1011101111, 1011110101, 1011111001, 1100000001, 1100000101, 1100010011, 1100011101, 1100101001, 1100101011, 1100110101, 1100110111, 1100111011, 1100111101, 1101000111, 1101010101, 1101011001, 1101011011, 1101011111, 1101101101, 1101110001, 1101110011, 1101110111, 1110001011, 1110001111, 1110010111, 1110100001, 1110101001, 1110101101, 1110110011, 1110111001, 1111000111, 1111001011, 1111010001, 1111010111, 1111011111, 1111100101, 1111110001, 1111110101, 1111111011, 1111111101, 10000000111, 10000001001, 10000001111, 10000011001, 10000011011, 10000100101, 10000100111, 10000101101, 10000111111, 10001000011, 10001000101, 10001001001, 10001001111, 10001010101, 10001011101, 10001100011, 10001101001, 10001111111, 10010000001, 10010001011, 10010010011, 10010011101, 10010100011, 10010101001, 10010110001, 10010111101, 10011000001, 10011000111

Ternary (Base-3)

2, 10, 12, 21, 102, 111, 122, 201, 212, 1002, 1011, 1101, 1112, 1121, 1202, 1222, 2012, 2021, 2111, 2122, 2201, 2221, 10002, 10022, 10121, 10202, 10211, 10222, 11001, 11012, 11201, 11212, 12002, 12011, 12112, 12121, 12211, 20001, 20012, 20102, 20122, 20201, 21002, 21011, 21022, 21101, 21211, 22021, 22102, 22111, 22122, 22212, 22221, 100022, 100112, 100202, 100222, 101001, 101021, 101102, 101111, 101212, 102101, 102112, 102121, 102202, 110021, 110111, 110212, 110221, 111002, 111022, 111121, 111211, 112001, 112012, 112102, 112201, 112212, 120011, 120112, 120121, 120222, 121001, 121021, 121102, 121122, 121221, 122002, 122011, 122022, 122202, 200001, 200012, 200111, 200122, 200212, 201022, 201101, 202001, 202021, 202122, 202212, 210002, 210011, 210101, 210202, 210222, 211012, 211021, 211111, 211201, 211212, 211221, 212101, 212202, 212211, 212222, 220012, 220102, 220111, 220221, 221002, 221022, 221121, 221222, 222021, 222122, 222221, 1000011, 1000101, 1000112, 1000211, 1001001, 1001012, 1001111, 1001122, 1002011, 1002112, 1002222, 1010001, 1010102, 1010111, 1010122, 1010201, 1011002, 1011121, 1011202, 1011211, 1011222, 1012111, 1012122, 1012201, 1012212, 1020121, 1020202, 1021001, 1021102, 1021201, 1021212, 1022002, 1022022, 1022211, 1022222, 1100012, 1100102, 1100201, 1100221, 1101101, 1101112, 1101202, 1101211, 1102012, 1102021, 1102111, 1102212, 1102221, 1110022, 1110101, 1110121, 1111021, 1111102, 1111111, 1111122, 1111212, 1112002, 1112101, 1112121, 1112211, 1120122, 1120201, 1121002, 1121101, 1121202, 1121222, 1122012, 1122111, 1122221, 1200002, 1200022

Quaternary (Base-4)

2, 3, 11, 13, 23, 31, 101, 103, 113, 131, 133, 211, 221, 223, 233, 311, 323, 331, 1003, 1013, 1021, 1033, 1103, 1121, 1201, 1211, 1213, 1223, 1231, 1301, 1333, 2003, 2021, 2023, 2111, 2113, 2131, 2203, 2213, 2231, 2303, 2311, 2333, 3001, 3011, 3013, 3103, 3133, 3203, 3211, 3221, 3233, 3301, 3323, 10001, 10013, 10031, 10033, 10111, 10121, 10123, 10211, 10303, 10313, 10321, 10331, 11023, 11101, 11123, 11131, 11201, 11213, 11233, 11311, 11323, 11333, 12011, 12031, 12101, 12121, 12203, 12211, 12233, 12301, 12313, 12323, 13001, 13021, 13031, 13033, 13103, 13133, 13213, 13223, 13303, 13313, 13331, 20021, 20023, 20131, 20203, 20231, 20303, 20321, 20323, 21001, 21023, 21101, 21113, 21121, 21133, 21211, 21221, 21223, 21313, 22001, 22003, 22013, 22031, 22103, 22111, 22201, 22211, 22223, 22303, 22331, 23011, 23033, 23113, 23131, 23203, 23213, 23233, 23311, 23321, 30001, 30011, 30103, 30131, 30221, 30223, 30311, 30313, 30323, 30331, 31013, 31111, 31121, 31123, 31133, 31231, 31301, 31303, 31313, 32023, 32033, 32113, 32201, 32221, 32231, 32303, 32321, 33013, 33023, 33101, 33113, 33133, 33211, 33301, 33311, 33323, 33331, 100013, 100021, 100033, 100121, 100123, 100211, 100213, 100231, 100333, 101003, 101011, 101021, 101033, 101111, 101131, 101203, 101221, 101333, 102001, 102023, 102103, 102131, 102203, 102221, 102301, 102331, 103001, 103013

Quinary (Base-5)

2, 3, 10, 12, 21, 23, 32, 34, 43, 104, 111, 122, 131, 133, 142, 203, 214, 221, 232, 241, 243, 304, 313, 324, 342, 401, 403, 412, 414, 423, 1002, 1011, 1022, 1024, 1044, 1101, 1112, 1123, 1132, 1143, 1204, 1211, 1231, 1233, 1242, 1244, 1321, 1343, 1402, 1404, 1413, 1424, 1431, 2001, 2012, 2023, 2034, 2041, 2102, 2111, 2113, 2133, 2212, 2221, 2223, 2232, 2311, 2322, 2342, 2344, 2403, 2414, 2432, 2443, 3004, 3013, 3024, 3042, 3101, 3114, 3134, 3141, 3211, 3213, 3224, 3233, 3244, 3312, 3321, 3323, 3332, 3404, 3422, 3431, 3444, 4003, 4014, 4041, 4043, 4131, 4142, 4212, 4223, 4234, 4241, 4302, 4322, 4333, 4344, 4401, 4412, 4423, 4432, 4434, 10011, 10031, 10033, 10042, 10103, 10114, 10121, 10143, 10202, 10213, 10231, 10301, 10314, 10334, 10402, 10413, 10424, 10433, 11001, 11012, 11021, 11034, 11043, 11122, 11142, 11214, 11221, 11241, 11243, 11302, 11304, 11324, 11403, 11412, 11414, 11423, 12002, 12011, 12013, 12022, 12112, 12121, 12134, 12204, 12222, 12231, 12242, 12303, 12332, 12341, 12402, 12413, 12431, 12442, 13014, 13023, 13034, 13041, 13111, 13113, 13124, 13144, 13201, 13221, 13223, 13234, 13322, 13331, 13333, 13342, 13403, 13414, 13432, 13443, 14004, 14101, 14103, 14123, 14141, 14211, 14222, 14233, 14301, 14323, 14332, 14343

Senary (Base-6)

2, 3, 5, 11, 15, 21, 25, 31, 35, 45, 51, 101, 105, 111, 115, 125, 135, 141, 151, 155, 201, 211, 215, 225, 241, 245, 251, 255, 301, 305, 331, 335, 345, 351, 405, 411, 421, 431, 435, 445, 455, 501, 515, 521, 525, 531, 551, 1011, 1015, 1021, 1025, 1035, 1041, 1055, 1105, 1115, 1125, 1131, 1141, 1145, 1151, 1205, 1231, 1235, 1241, 1245, 1311, 1321, 1335, 1341, 1345, 1355, 1411, 1421, 1431, 1435, 1445, 1501, 1505, 1521, 1535, 1541, 1555, 2001, 2011, 2015, 2025, 2041, 2045, 2051, 2055, 2115, 2131, 2135, 2151, 2155, 2205, 2225, 2231, 2301, 2311, 2325, 2335, 2345, 2351, 2401, 2415, 2425, 2435, 2441, 2451, 2501, 2505, 2511, 2531, 2545, 2551, 2555, 3005, 3015, 3021, 3041, 3045, 3055, 3111, 3125, 3141, 3155, 3211, 3221, 3231, 3235, 3251, 3301, 3305, 3321, 3325, 3351, 3405, 3425, 3431, 3445, 3451, 3455, 3501, 3515, 3541, 3545, 3551, 3555, 4021, 4025, 4031, 4035, 4111, 4115, 4131, 4145, 4201, 4205, 4215, 4225, 4251, 4255, 4305, 4315, 4331, 4341, 4401, 4405, 4415, 4421, 4435, 4441, 4451, 4505, 4511, 4525, 4531, 4541, 5011, 5015, 5021, 5025, 5035, 5045, 5101, 5111, 5121, 5155, 5201, 5215, 5231, 5245, 5255, 5305, 5321, 5341, 5345, 5355

Septenary (Base-7)

2, 3, 5, 10, 14, 16, 23, 25, 32, 41, 43, 52, 56, 61, 65, 104, 113, 115, 124, 131, 133, 142, 146, 155, 166, 203, 205, 212, 214, 221, 241, 245, 254, 256, 302, 304, 313, 322, 326, 335, 344, 346, 362, 364, 401, 403, 421, 436, 443, 445, 452, 461, 463, 506, 515, 524, 533, 535, 544, 551, 553, 566, 616, 623, 625, 632, 652, 661, 1004, 1006, 1013, 1022, 1033, 1042, 1051, 1055, 1064, 1105, 1112, 1123, 1136, 1141, 1154, 1156, 1165, 1202, 1211, 1222, 1226, 1231, 1235, 1253, 1264, 1301, 1312, 1316, 1325, 1343, 1345, 1402, 1411, 1424, 1433, 1442, 1444, 1453, 1466, 1505, 1514, 1516, 1525, 1534, 1541, 1543, 1561, 1604, 1606, 1613, 1622, 1631, 1633, 1651, 1655, 1664, 2005, 2021, 2032, 2045, 2056, 2065, 2104, 2111, 2122, 2131, 2135, 2146, 2153, 2203, 2216, 2234, 2236, 2252, 2254, 2261, 2263, 2306, 2326, 2333, 2335, 2342, 2362, 2366, 2401, 2405, 2434, 2441, 2452, 2465, 2506, 2513, 2522, 2531, 2551, 2555, 2564, 2603, 2614, 2623, 2641, 2645, 2654, 2656, 3002, 3004, 3013, 3026, 3031, 3044, 3046, 3055, 3112, 3116, 3121, 3125, 3134, 3143, 3154, 3163, 3202, 3233, 3235, 3251, 3262, 3305, 3314, 3323, 3334, 3352, 3356, 3365

Octal (Base-8)

2, 3, 5, 7, 13, 15, 21, 23, 27, 35, 37, 45, 51, 53, 57, 65, 73, 75, 103, 107, 111, 117, 123, 131, 141, 145, 147, 153, 155, 161, 177, 203, 211, 213, 225, 227, 235, 243, 247, 255, 263, 265, 277, 301, 305, 307, 323, 337, 343, 345, 351, 357, 361, 373, 401, 407, 415, 417, 425, 431, 433, 445, 463, 467, 471, 475, 513, 521, 533, 535, 541, 547, 557, 565, 573, 577, 605, 615, 621, 631, 643, 645, 657, 661, 667, 673, 701, 711, 715, 717, 723, 737, 747, 753, 763, 767, 775, 1011, 1013, 1035, 1043, 1055, 1063, 1071, 1073, 1101, 1113, 1121, 1127, 1131, 1137, 1145, 1151, 1153, 1167, 1201, 1203, 1207, 1215, 1223, 1225, 1241, 1245, 1253, 1263, 1275, 1305, 1317, 1327, 1335, 1343, 1347, 1357, 1365, 1371, 1401, 1405, 1423, 1435, 1451, 1453, 1465, 1467, 1473, 1475, 1507, 1525, 1531, 1533, 1537, 1555, 1561, 1563, 1567, 1613, 1617, 1627, 1641, 1651, 1655, 1663, 1671, 1707, 1713, 1721, 1727, 1737, 1745, 1761, 1765, 1773, 1775, 2007, 2011, 2017, 2031, 2033, 2045, 2047, 2055, 2077, 2103, 2105, 2111, 2117, 2125, 2135, 2143, 2151, 2177, 2201, 2213, 2223, 2235, 2243, 2251, 2261, 2275, 2301, 2307

Nonary (Base-9)

2, 3, 5, 7, 12, 14, 18, 21, 25, 32, 34, 41, 45, 47, 52, 58, 65, 67, 74, 78, 81, 87, 102, 108, 117, 122, 124, 128, 131, 135, 151, 155, 162, 164, 175, 177, 184, 201, 205, 212, 218, 221, 232, 234, 238, 241, 254, 267, 272, 274, 278, 285, 287, 308, 315, 322, 328, 331, 337, 342, 344, 355, 371, 375, 377, 382, 407, 414, 425, 427, 432, 438, 447, 454, 461, 465, 472, 481, 485, 504, 515, 517, 528, 531, 537, 542, 548, 557, 562, 564, 568, 582, 601, 605, 614, 618, 625, 638, 641, 661, 667, 678, 685, 702, 704, 711, 722, 728, 735, 737, 744, 751, 755, 757, 771, 782, 784, 788, 805, 812, 814, 827, 832, 838, 847, 858, 867, 878, 887, 1004, 1011, 1015, 1024, 1031, 1035, 1044, 1048, 1064, 1075, 1088, 1101, 1112, 1114, 1118, 1121, 1132, 1147, 1152, 1154, 1158, 1174, 1178, 1181, 1185, 1217, 1222, 1231, 1242, 1251, 1255, 1262, 1268, 1284, 1288, 1305, 1312, 1321, 1327, 1341, 1345, 1352, 1354, 1365, 1367, 1374, 1385, 1387, 1408, 1411, 1417, 1437, 1442, 1444, 1448, 1455, 1462, 1471, 1477, 1484, 1518, 1521, 1532, 1541, 1552, 1558, 1565, 1574, 1587, 1602, 1608


Hexadecimal (Base-16)

\\ PARI/GP
\\ x = base-10 number to convert
\\ b = base to convert it to
convert_base(x, b) = {
\(\qquad\)if (x == 0, return (“0”));
\(\qquad\)my (a = “”, \\ string to store result
\(\qquad\qquad\)dig = Vec(“0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ”), \\ possible digits
\(\qquad\qquad\)n = digits(x, b)
\(\qquad\));
\(\qquad\)for (i = 1, #n, a = concat(a, dig[n[i] + 1]));
\(\qquad\)return (a);
}
forprime (y = 0, 1223, print1(convert_base(y, 16), “, “));
2, 3, 5, 7, B, D, 11, 13, 17, 1D, 1F, 25, 29, 2B, 2F, 35, 3B, 3D, 43, 47, 49, 4F, 53, 59, 61, 65, 67, 6B, 6D, 71, 7F, 83, 89, 8B, 95, 97, 9D, A3, A7, AD, B3, B5, BF, C1, C5, C7, D3, DF, E3, E5, E9, EF, F1, FB, 101, 107, 10D, 10F, 115, 119, 11B, 125, 133, 137, 139, 13D, 14B, 151, 15B, 15D, 161, 167, 16F, 175, 17B, 17F, 185, 18D, 191, 199, 1A3, 1A5, 1AF, 1B1, 1B7, 1BB, 1C1, 1C9, 1CD, 1CF, 1D3, 1DF, 1E7, 1EB, 1F3, 1F7, 1FD, 209, 20B, 21D, 223, 22D, 233, 239, 23B, 241, 24B, 251, 257, 259, 25F, 265, 269, 26B, 277, 281, 283, 287, 28D, 293, 295, 2A1, 2A5, 2AB, 2B3, 2BD, 2C5, 2CF, 2D7, 2DD, 2E3, 2E7, 2EF, 2F5, 2F9, 301, 305, 313, 31D, 329, 32B, 335, 337, 33B, 33D, 347, 355, 359, 35B, 35F, 36D, 371, 373, 377, 38B, 38F, 397, 3A1, 3A9, 3AD, 3B3, 3B9, 3C7, 3CB, 3D1, 3D7, 3DF, 3E5, 3F1, 3F5, 3FB, 3FD, 407, 409, 40F, 419, 41B, 425, 427, 42D, 43F, 443, 445, 449, 44F, 455, 45D, 463, 469, 47F, 481, 48B, 493, 49D, 4A3, 4A9, 4B1, 4BD, 4C1, 4C7

Vigesimal (Base-20)

2, 3, 5, 7, B, D, H, J, 13, 19, 1B, 1H, 21, 23, 27, 2D, 2J, 31, 37, 3B, 3D, 3J, 43, 49, 4H, 51, 53, 57, 59, 5D, 67, 6B, 6H, 6J, 79, 7B, 7H, 83, 87, 8D, 8J, 91, 9B, 9D, 9H, 9J, AB, B3, B7, B9, BD, BJ, C1, CB, CH, D3, D9, DB, DH, E1, E3, ED, F7, FB, FD, FH, GB, GH, H7, H9, HD, HJ, I7, ID, IJ, J3, J9, JH, 101, 109, 10J, 111, 11B, 11D, 11J, 123, 129, 12H, 131, 133, 137, 13J, 147, 14B, 14J, 153, 159, 161, 163, 171, 177, 17H, 183, 189, 18B, 18H, 197, 19D, 19J, 1A1, 1A7, 1AD, 1AH, 1AJ, 1BB, 1C1, 1C3, 1C7, 1CD, 1CJ, 1D1, 1DD, 1DH, 1E3, 1EB, 1F1, 1F9, 1FJ, 1G7, 1GD, 1GJ, 1H3, 1HB, 1HH, 1I1, 1I9, 1ID, 1J7, 1JH, 209, 20B, 211, 213, 217, 219, 21J, 22D, 22H, 22J, 233, 23H, 241, 243, 247, 257, 25B, 25J, 269, 26H, 271, 277, 27D, 287, 28B, 28H, 293, 29B, 29H, 2A9, 2AD, 2AJ, 2B1, 2BB, 2BD, 2BJ, 2C9, 2CB, 2D1, 2D3, 2D9, 2E7, 2EB, 2ED, 2EH, 2F3, 2F9, 2FH, 2G3, 2G9, 2HB, 2HD, 2I3, 2IB, 2J1, 2J7, 2JD, 301, 30D, 30H, 313

Leave a Reply