{"id":17282,"date":"2026-03-16T11:14:38","date_gmt":"2026-03-16T15:14:38","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=17282"},"modified":"2026-04-01T13:04:45","modified_gmt":"2026-04-01T17:04:45","slug":"matlab-user-john-derrico-finds-largest-known-reversible-prime-with-12346-digits","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2026\/03\/16\/matlab-user-john-derrico-finds-largest-known-reversible-prime-with-12346-digits\/","title":{"rendered":"MATLAB user John D&#8217;Errico finds largest known reversible prime with 12,346 digits"},"content":{"rendered":"<div class=\"rtcContent\">\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Mike's pick this week is a <a href=\"https:\/\/uk.mathworks.com\/matlabcentral\/discussions\/general\/887061-what-is-an-emirp-can-we-find-a-new-world-record-size-prime-of-this-form-using-only-matlab-and-a-h?s_tid=mlc_com_per_disc\">candidate for the new world-record reversible prime number<\/a> found by <a href=\"https:\/\/uk.mathworks.com\/matlabcentral\/profile\/authors\/869215\">John D'Errico<\/a>.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">A reversible prime, (also known as an emirp), is a prime number that yields a different prime when its digits are reversed. An example is 13. Reversing this gives 31 and both are prime<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 15px 10px 0; display: inline-block; min-width: 100%;\">\r\n<div class=\"inlineWrapper outputs\">\r\n<div style=\"border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace, Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">isprime([13 31])<\/span><\/div>\r\n<div style=\"color: #212121; padding: 10px 0px 6px 17px; background: #ffffff none repeat scroll 0% 0% \/ auto padding-box border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px;\">\r\n<div class=\"inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableMatrixElement\" style=\"width: 1289.33px; white-space: normal; font-style: normal; color: #212121; font-size: 12px;\" tabindex=\"-1\" data-testid=\"output_0\" data-width=\"1259\">\r\n<div class=\"outputLayer selectedOutputDecorationLayer doNotExport\" style=\"white-space: normal; font-style: normal; color: #212121; font-size: 12px;\" aria-hidden=\"true\"><\/div>\r\n<div class=\"outputLayer scrollableOutputDecorationLayer doNotExport\" style=\"white-space: normal; font-style: normal; color: #212121; font-size: 12px;\" aria-hidden=\"true\"><\/div>\r\n<div class=\"outputLayer navigationFocusLayer doNotExport\" style=\"white-space: normal; font-style: normal; color: #212121; font-size: 12px;\" tabindex=\"-1\" role=\"application\" aria-hidden=\"false\"><\/div>\r\n<div class=\"outputLayer activeOutputDecorationLayer doNotExport\" style=\"white-space: normal; font-style: normal; color: #212121; font-size: 12px;\" role=\"application\" aria-hidden=\"false\"><\/div>\r\n<div class=\"matrixElement veSpecifier saveLoad eoOutputContent\" style=\"white-space: normal; font-style: normal; color: #212121; font-size: 12px;\" role=\"article\" aria-roledescription=\"Use Browse Mode to explore \" aria-description=\"variable output \">\r\n<div class=\"veVariableName variableNameElement\" style=\"width: 1259px; white-space: normal; font-style: normal; color: #212121; font-size: 12px;\">\r\n<div class=\"headerElementClickToInteract\" style=\"white-space: normal; font-style: normal; color: #212121; font-size: 12px;\"><span style=\"white-space: normal; font-style: normal; color: #212121; font-size: 12px;\">ans = <\/span><span class=\"veVariableValueSummary headerElement\" style=\"white-space: normal; font-style: italic; color: #616161; font-size: 12px;\">1\u00d72 logical array<\/span><\/div>\r\n<\/div>\r\n<div class=\"valueContainer\" style=\"white-space: nowrap; font-style: normal; color: #212121; font-size: 12px;\" data-layout=\"{&quot;columnWidth&quot;:29,&quot;totalColumns&quot;:2,&quot;totalRows&quot;:1,&quot;charsPerColumn&quot;:4}\">\r\n<div class=\"variableValue\" style=\"width: 60px; white-space: pre; font-style: normal; color: #212121; font-size: 12px;\">1 1<\/div>\r\n<div class=\"horizontalEllipsis hide\" style=\"white-space: nowrap; font-style: normal; color: #212121; font-size: 12px;\"><\/div>\r\n<div class=\"verticalEllipsis hide\" style=\"white-space: nowrap; font-style: normal; color: #212121; font-size: 12px;\"><\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Checking if small numbers are emirp is relatively straightforward but things get rather more complex when we start looking at larger numbers. <a href=\"https:\/\/www.youtube.com\/watch?v=6cw9QJw6J60\">Matt Parker's Numberphile<\/a> recently discussed the discovery of the (then) largest known emirp. It had 10,002 decimal digits. Wikipedia currently lists 117,954,861 \u00d7 1011,111 + 1 as the largest known emirp with which has 11,120 digits.<\/div>\r\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">How MATLAB user, John D'Errico, found a 12,346 digit emirp<\/h2>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The short version of the story is that John looked for emirps of the form 10^n + a and used <a href=\"https:\/\/uk.mathworks.com\/products\/symbolic.html\">symbolic toolbox<\/a> and <a href=\"https:\/\/uk.mathworks.com\/products\/parallel-computing.html\">parallel computing toolbox<\/a> to make use of all 16 cores on his desktop computer to burn through the search space. The result is that he found that <span style=\"font-family: monospace;\">10^12338*79191501 + 1<\/span> is a 12,346 digit emirp, currently the largest known (although I'd prefer us to get independent verification before we suggest an update the Wikipedia page).<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Why he chose that particular form of emirp, all of this code and full discussion of his journey can be found in <a href=\"https:\/\/uk.mathworks.com\/matlabcentral\/discussions\/general\/887061-what-is-an-emirp-can-we-find-a-new-world-record-size-prime-of-this-form-using-only-matlab-and-a-h?s_tid=mlc_com_per_disc\">this MATLAB discussion thread.<\/a> I found it fascinating to follow him on his journey from 'This is a promising candidate' to 'We can say that it's highly probable that this is an emirp' to 'This is definitely an emirp'! Great work John!<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">We fully expect, and hope, that this record will not stand for long. Happy hunting!<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\r\n<\/div>\r\n<script type=\"text\/javascript\">var css = '.eoOutputWrapper { width: calc(90vw - 10px) !important; } .variableValue { width: 100% !important; } \/* Copyright 2014-2025 The MathWorks, Inc. *\/.embeddedOutputsMatrixElement,.eoOutputWrapper .matrixElement {    min-height: 18px;    box-sizing: border-box;} .embeddedOutputsMatrixElement .matrixElement,.eoOutputWrapper .matrixElement {    position: relative;} .matrixElement .variableValue {    white-space: pre;    display: inline-block;    vertical-align: top;    overflow: hidden;} .embeddedOutputsMatrixElement.inlineElement {} .embeddedOutputsMatrixElement.inlineElement .topHeaderWrapper {    display: none;} .embeddedOutputsMatrixElement.inlineElement .veTable .body {    padding-top: 0 !important;    max-height: 100px;} .inlineElement .matrixElement {    max-height: 300px;} .embeddedOutputsMatrixElement.rightPaneElement {} .rightPaneElement .matrixElement,.rtcDataTipElement .matrixElement {    overflow: hidden;    padding-left: 9px;} .rightPaneElement .matrixElement {    margin-bottom: -1px;} .embeddedOutputsMatrixElement .matrixElement .valueContainer,.eoOutputWrapper .matrixElement .valueContainer {    white-space: nowrap;    margin-bottom: 3px;} .embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis.hide,.embeddedOutputsMatrixElement .matrixElement .verticalEllipsis.hide,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis.hide,.eoOutputWrapper .matrixElement .verticalEllipsis.hide {    display: none;} .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .verticalEllipsis, .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .horizontalEllipsis {    display:none;} .eoOutputWrapper .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer {    \/* Note: This seems like an invalid CSS selector because eoOutputWrapper and    embeddedOutputsVariableMatrixElement are applied to the same DOM node. However, if we change it    to `.eoOutputWrapper.embeddedOutputsVariableMatrixElement .matrixElement .valueContainer` then    one test point in tCSSStyles.js would fail because it expects the cursor to be `pointer`. Nanda    will revisit this. *\/    cursor: default !important;} \/* Copyright 2014-2025 The MathWorks, Inc. *\/.embeddedOutputsVariableElement {    white-space: pre-wrap;    word-wrap: break-word;    min-height: 18px;    max-height: 250px;    overflow: auto;} .eoOutputWrapper .variableElement {    padding-top: 2px;} .embeddedOutputsVariableElement.rightPaneElement {    min-height: 16px;} .rightPaneElement .variableElement {    padding-left: 9px;} .outputsOnRight .embeddedOutputsVariableElement.rightPaneElement .eoOutputContent {    \/* Remove extra space allocated for navigation border *\/    margin-top: 0;    margin-bottom: 0;} .variableNameElement {    margin-bottom: 3px;    display: inline-block;} \/* * Ellipses as base64 for HTML export. *\/.matrixElement .horizontalEllipsis,.rtcDataTipElement .matrixElement .horizontalEllipsis {    display: inline-block;    margin-top: 3px;    \/* base64 encoded version of images-liveeditor\/HEllipsis.png *\/    width: 30px;    height: 12px;    background-repeat: no-repeat;    background-image: url(\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAJCAYAAADO1CeCAAAAJUlEQVR42mP4\/\/8\/A70xw0i29BUDFPxnAEtTW37wWDqakIa4pQDvOOG89lHX2gAAAABJRU5ErkJggg==\");} .matrixElement .verticalEllipsis,.textElement .verticalEllipsis,.rtcDataTipElement .matrixElement .verticalEllipsis,.rtcDataTipElement .textElement .verticalEllipsis {    margin-left: 35px;    \/* base64 encoded version of images-liveeditor\/VEllipsis.png *\/    width: 12px;    height: 30px;    background-repeat: no-repeat;    background-image: url(\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAZCAYAAAAIcL+IAAAALklEQVR42mP4\/\/8\/AzGYgWyFMECMwv8QddRS+P\/\/KyimlmcGUOFoOI6GI\/UVAgDnd8Dd4+NCwgAAAABJRU5ErkJggg==\");}'; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/pick\/files\/Designer-2.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>\r\nMike's pick this week is a candidate for the new world-record reversible prime number found by John D'Errico.\r\nA reversible prime, (also known as an emirp), is a prime number that yields a... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2026\/03\/16\/matlab-user-john-derrico-finds-largest-known-reversible-prime-with-12346-digits\/\">read more >><\/a><\/p>","protected":false},"author":176,"featured_media":17295,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[71],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/17282"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/176"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=17282"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/17282\/revisions"}],"predecessor-version":[{"id":17296,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/17282\/revisions\/17296"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media\/17295"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=17282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=17282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=17282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}