CINXE.COM
Lucas–Lehmer primality test - Wikipedia
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>Lucas–Lehmer primality test - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy", "wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"587c77ed-1a96-477f-9a68-03150c2ab45e","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Lucas–Lehmer_primality_test","wgTitle":"Lucas–Lehmer primality test","wgCurRevisionId":1251698132,"wgRevisionId":1251698132,"wgArticleId":325739,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description is different from Wikidata","Articles contradicting other articles","Wikipedia articles needing clarification from September 2022","Primality tests","Mersenne primes"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Lucas–Lehmer_primality_test","wgRelevantArticleId":325739,"wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true, "wgRestrictionEdit":[],"wgRestrictionMove":[],"wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":20000,"wgRelatedArticlesCompat":[],"wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q1138992","wgCheckUserClientHintsHeadersJsApi":["brands","architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false, "wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.cite.styles":"ready","ext.math.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","jquery.makeCollapsible.styles":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["ext.cite.ux-enhancements","site","mediawiki.page.ready","jquery.makeCollapsible","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp","ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","ext.popups","ext.visualEditor.desktopArticleTarget.init", "ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.growthExperiments.SuggestedEditSession","wikibase.sidebar.tracking"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&modules=ext.cite.styles%7Cext.math.styles%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediaBadges%7Cext.wikimediamessages.styles%7Cjquery.makeCollapsible.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="Lucas–Lehmer primality test - Wikipedia"> <meta property="og:type" content="website"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primality_test"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primality_test"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-Lucas–Lehmer_primality_test rootpage-Lucas–Lehmer_primality_test skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li> </ul> </div> </div> <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" > <div class="vector-menu-heading"> Contribute </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Main_Page" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page's font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&returnto=Lucas%E2%80%93Lehmer+primality+test" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&returnto=Lucas%E2%80%93Lehmer+primality+test" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&returnto=Lucas%E2%80%93Lehmer+primality+test" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&returnto=Lucas%E2%80%93Lehmer+primality+test" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">(Top)</div> </a> </li> <li id="toc-The_test" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#The_test"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>The test</span> </div> </a> <button aria-controls="toc-The_test-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle The test subsection</span> </button> <ul id="toc-The_test-sublist" class="vector-toc-list"> <li id="toc-Alternate_starting_values" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Alternate_starting_values"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.1</span> <span>Alternate starting values</span> </div> </a> <ul id="toc-Alternate_starting_values-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Sign_of_penultimate_term" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Sign_of_penultimate_term"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2</span> <span>Sign of penultimate term</span> </div> </a> <ul id="toc-Sign_of_penultimate_term-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Time_complexity" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Time_complexity"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Time complexity</span> </div> </a> <ul id="toc-Time_complexity-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Examples" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Examples"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Examples</span> </div> </a> <ul id="toc-Examples-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Proof_of_correctness" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Proof_of_correctness"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Proof of correctness</span> </div> </a> <button aria-controls="toc-Proof_of_correctness-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Proof of correctness subsection</span> </button> <ul id="toc-Proof_of_correctness-sublist" class="vector-toc-list"> <li id="toc-Sufficiency" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Sufficiency"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.1</span> <span>Sufficiency</span> </div> </a> <ul id="toc-Sufficiency-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Necessity" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Necessity"> <div class="vector-toc-text"> <span class="vector-toc-numb">4.2</span> <span>Necessity</span> </div> </a> <ul id="toc-Necessity-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Applications" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Applications"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>Applications</span> </div> </a> <ul id="toc-Applications-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Notes" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Notes"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>Notes</span> </div> </a> <ul id="toc-Notes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>External links</span> </div> </a> <ul id="toc-External_links-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Lucas–Lehmer primality test</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Go to an article in another language. Available in 16 languages" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-16" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">16 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-ar mw-list-item"><a href="https://ar.wikipedia.org/wiki/%D8%A7%D8%AE%D8%AA%D8%A8%D8%A7%D8%B1_%D9%84%D9%88%D9%83%D8%A7%D8%B3_%D9%84%D9%8A%D9%87%D9%85%D8%B1_%D9%84%D8%A3%D9%88%D9%84%D9%8A%D8%A9_%D8%B9%D8%AF%D8%AF_%D9%85%D8%A7" title="اختبار لوكاس ليهمر لأولية عدد ما – Arabic" lang="ar" hreflang="ar" data-title="اختبار لوكاس ليهمر لأولية عدد ما" data-language-autonym="العربية" data-language-local-name="Arabic" class="interlanguage-link-target"><span>العربية</span></a></li><li class="interlanguage-link interwiki-ca mw-list-item"><a href="https://ca.wikipedia.org/wiki/Prova_de_Lucas-Lehmer_per_a_nombres_de_Mersenne" title="Prova de Lucas-Lehmer per a nombres de Mersenne – Catalan" lang="ca" hreflang="ca" data-title="Prova de Lucas-Lehmer per a nombres de Mersenne" data-language-autonym="Català" data-language-local-name="Catalan" class="interlanguage-link-target"><span>Català</span></a></li><li class="interlanguage-link interwiki-da mw-list-item"><a href="https://da.wikipedia.org/wiki/Lucas-Lehmer" title="Lucas-Lehmer – Danish" lang="da" hreflang="da" data-title="Lucas-Lehmer" data-language-autonym="Dansk" data-language-local-name="Danish" class="interlanguage-link-target"><span>Dansk</span></a></li><li class="interlanguage-link interwiki-de mw-list-item"><a href="https://de.wikipedia.org/wiki/Lucas-Lehmer-Test" title="Lucas-Lehmer-Test – German" lang="de" hreflang="de" data-title="Lucas-Lehmer-Test" data-language-autonym="Deutsch" data-language-local-name="German" class="interlanguage-link-target"><span>Deutsch</span></a></li><li class="interlanguage-link interwiki-es mw-list-item"><a href="https://es.wikipedia.org/wiki/Test_de_Lucas-Lehmer" title="Test de Lucas-Lehmer – Spanish" lang="es" hreflang="es" data-title="Test de Lucas-Lehmer" data-language-autonym="Español" data-language-local-name="Spanish" class="interlanguage-link-target"><span>Español</span></a></li><li class="interlanguage-link interwiki-fr mw-list-item"><a href="https://fr.wikipedia.org/wiki/Test_de_primalit%C3%A9_de_Lucas-Lehmer_pour_les_nombres_de_Mersenne" title="Test de primalité de Lucas-Lehmer pour les nombres de Mersenne – French" lang="fr" hreflang="fr" data-title="Test de primalité de Lucas-Lehmer pour les nombres de Mersenne" data-language-autonym="Français" data-language-local-name="French" class="interlanguage-link-target"><span>Français</span></a></li><li class="interlanguage-link interwiki-ko mw-list-item"><a href="https://ko.wikipedia.org/wiki/%EB%A4%BC%EC%B9%B4-%EB%A0%88%EB%A8%B8_%EC%86%8C%EC%88%98%ED%8C%90%EB%B3%84%EB%B2%95" title="뤼카-레머 소수판별법 – Korean" lang="ko" hreflang="ko" data-title="뤼카-레머 소수판별법" data-language-autonym="한국어" data-language-local-name="Korean" class="interlanguage-link-target"><span>한국어</span></a></li><li class="interlanguage-link interwiki-it mw-list-item"><a href="https://it.wikipedia.org/wiki/Test_di_Lucas-Lehmer" title="Test di Lucas-Lehmer – Italian" lang="it" hreflang="it" data-title="Test di Lucas-Lehmer" data-language-autonym="Italiano" data-language-local-name="Italian" class="interlanguage-link-target"><span>Italiano</span></a></li><li class="interlanguage-link interwiki-he mw-list-item"><a href="https://he.wikipedia.org/wiki/%D7%9E%D7%91%D7%97%D7%9F_%D7%9C%D7%95%D7%A7%D7%90%D7%A1-%D7%9C%D7%94%D7%9E%D7%A8_%D7%9C%D7%9E%D7%A1%D7%A4%D7%A8%D7%99_%D7%9E%D7%A8%D7%A1%D7%9F" title="מבחן לוקאס-להמר למספרי מרסן – Hebrew" lang="he" hreflang="he" data-title="מבחן לוקאס-להמר למספרי מרסן" data-language-autonym="עברית" data-language-local-name="Hebrew" class="interlanguage-link-target"><span>עברית</span></a></li><li class="interlanguage-link interwiki-nl mw-list-item"><a href="https://nl.wikipedia.org/wiki/Lucas-Lehmertest_voor_mersennegetallen" title="Lucas-Lehmertest voor mersennegetallen – Dutch" lang="nl" hreflang="nl" data-title="Lucas-Lehmertest voor mersennegetallen" data-language-autonym="Nederlands" data-language-local-name="Dutch" class="interlanguage-link-target"><span>Nederlands</span></a></li><li class="interlanguage-link interwiki-ja badge-Q70893996 mw-list-item" title=""><a href="https://ja.wikipedia.org/wiki/%E3%83%AA%E3%83%A5%E3%82%AB%E2%80%93%E3%83%AC%E3%83%BC%E3%83%9E%E3%83%BC%E3%83%BB%E3%83%86%E3%82%B9%E3%83%88" title="リュカ–レーマー・テスト – Japanese" lang="ja" hreflang="ja" data-title="リュカ–レーマー・テスト" data-language-autonym="日本語" data-language-local-name="Japanese" class="interlanguage-link-target"><span>日本語</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Test_Lucasa-Lehmera" title="Test Lucasa-Lehmera – Polish" lang="pl" hreflang="pl" data-title="Test Lucasa-Lehmera" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li><li class="interlanguage-link interwiki-ru badge-Q17437798 badge-goodarticle mw-list-item" title="good article badge"><a href="https://ru.wikipedia.org/wiki/%D0%A2%D0%B5%D1%81%D1%82_%D0%9B%D1%8E%D0%BA%D0%B0_%E2%80%94_%D0%9B%D0%B5%D0%BC%D0%B5%D1%80%D0%B0" title="Тест Люка — Лемера – Russian" lang="ru" hreflang="ru" data-title="Тест Люка — Лемера" data-language-autonym="Русский" data-language-local-name="Russian" class="interlanguage-link-target"><span>Русский</span></a></li><li class="interlanguage-link interwiki-fi mw-list-item"><a href="https://fi.wikipedia.org/wiki/Lucasin_ja_Lehmerin_alkulukutesti_Mersennen_luvuille" title="Lucasin ja Lehmerin alkulukutesti Mersennen luvuille – Finnish" lang="fi" hreflang="fi" data-title="Lucasin ja Lehmerin alkulukutesti Mersennen luvuille" data-language-autonym="Suomi" data-language-local-name="Finnish" class="interlanguage-link-target"><span>Suomi</span></a></li><li class="interlanguage-link interwiki-uk mw-list-item"><a href="https://uk.wikipedia.org/wiki/%D0%A2%D0%B5%D1%81%D1%82_%D0%9B%D1%8E%D0%BA%D0%B0_%E2%80%94_%D0%9B%D0%B5%D0%BC%D0%B5%D1%80%D0%B0" title="Тест Люка — Лемера – Ukrainian" lang="uk" hreflang="uk" data-title="Тест Люка — Лемера" data-language-autonym="Українська" data-language-local-name="Ukrainian" class="interlanguage-link-target"><span>Українська</span></a></li><li class="interlanguage-link interwiki-zh mw-list-item"><a href="https://zh.wikipedia.org/wiki/%E5%8D%A2%E5%8D%A1%E6%96%AF-%E8%8E%B1%E9%BB%98%E6%A3%80%E9%AA%8C%E6%B3%95" title="卢卡斯-莱默检验法 – Chinese" lang="zh" hreflang="zh" data-title="卢卡斯-莱默检验法" data-language-autonym="中文" data-language-local-name="Chinese" class="interlanguage-link-target"><span>中文</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q1138992#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Lucas%E2%80%93Lehmer_primality_test" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:Lucas%E2%80%93Lehmer_primality_test" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/Lucas%E2%80%93Lehmer_primality_test"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/Lucas%E2%80%93Lehmer_primality_test"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/Lucas%E2%80%93Lehmer_primality_test" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/Lucas%E2%80%93Lehmer_primality_test" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&oldid=1251698132" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&page=Lucas%E2%80%93Lehmer_primality_test&id=1251698132&wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLucas%25E2%2580%2593Lehmer_primality_test"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLucas%25E2%2580%2593Lehmer_primality_test"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&page=Lucas%E2%80%93Lehmer_primality_test&action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q1138992" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">Test if a Mersenne number is prime</div> <style data-mw-deduplicate="TemplateStyles:r1236090951">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}</style><div role="note" class="hatnote navigation-not-searchable">This article is about the Lucas–Lehmer test that applies only to Mersenne numbers. For the Lucas–Lehmer test that applies to a natural number <i>n</i>, see <a href="/wiki/Lucas_primality_test" title="Lucas primality test">Lucas primality test</a>. For the Lucas–Lehmer–Riesel test, see <a href="/wiki/Lucas%E2%80%93Lehmer%E2%80%93Riesel_test" title="Lucas–Lehmer–Riesel test">Lucas–Lehmer–Riesel test</a>.</div> <p>In <a href="/wiki/Mathematics" title="Mathematics">mathematics</a>, the <b>Lucas–Lehmer test</b> (<b>LLT</b>) is a <a href="/wiki/Primality_test" title="Primality test">primality test</a> for <a href="/wiki/Mersenne_prime" title="Mersenne prime">Mersenne numbers</a>. The test was originally developed by <a href="/wiki/%C3%89douard_Lucas" title="Édouard Lucas">Édouard Lucas</a> in 1878<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> and subsequently proved by <a href="/wiki/Derrick_Henry_Lehmer" class="mw-redirect" title="Derrick Henry Lehmer">Derrick Henry Lehmer</a> in 1930. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="The_test">The test</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=1" title="Edit section: The test"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The Lucas–Lehmer test works as follows. Let <i>M</i><sub><i>p</i></sub> = 2<sup><i>p</i></sup> − 1 be the Mersenne number to test with <i>p</i> an odd <a href="/wiki/Prime_number" title="Prime number">prime</a>. The primality of <i>p</i> can be efficiently checked with a simple algorithm like <a href="/wiki/Trial_division" title="Trial division">trial division</a> since <i>p</i> is exponentially smaller than <i>M</i><sub><i>p</i></sub>. Define a sequence <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{s_{i}\}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo fence="false" stretchy="false">{</mo> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> </mrow> </msub> <mo fence="false" stretchy="false">}</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \{s_{i}\}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/dd1ae018894d935d40725639ef12ae372e2b02cd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:4.215ex; height:2.843ex;" alt="{\displaystyle \{s_{i}\}}"></span> for all <i>i</i> ≥ 0 by </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{i}={\begin{cases}4&{\text{if }}i=0;\\s_{i-1}^{2}-2&{\text{otherwise.}}\end{cases}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> </mrow> </msub> <mo>=</mo> <mrow class="MJX-TeXAtom-ORD"> <mrow> <mo>{</mo> <mtable columnalign="left left" rowspacing=".2em" columnspacing="1em" displaystyle="false"> <mtr> <mtd> <mn>4</mn> </mtd> <mtd> <mrow class="MJX-TeXAtom-ORD"> <mtext>if </mtext> </mrow> <mi>i</mi> <mo>=</mo> <mn>0</mn> <mo>;</mo> </mtd> </mtr> <mtr> <mtd> <msubsup> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msubsup> <mo>−<!-- − --></mo> <mn>2</mn> </mtd> <mtd> <mrow class="MJX-TeXAtom-ORD"> <mtext>otherwise.</mtext> </mrow> </mtd> </mtr> </mtable> <mo fence="true" stretchy="true" symmetric="true"></mo> </mrow> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{i}={\begin{cases}4&{\text{if }}i=0;\\s_{i-1}^{2}-2&{\text{otherwise.}}\end{cases}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4212bd376678838f4f69192f5f498bf3d03c5f67" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.505ex; width:28.023ex; height:6.176ex;" alt="{\displaystyle s_{i}={\begin{cases}4&{\text{if }}i=0;\\s_{i-1}^{2}-2&{\text{otherwise.}}\end{cases}}}"></span></dd></dl> <p>The first few terms of this sequence are 4, 14, 194, 37634, ... (sequence <span class="nowrap external"><a href="//oeis.org/A003010" class="extiw" title="oeis:A003010">A003010</a></span> in the <a href="/wiki/On-Line_Encyclopedia_of_Integer_Sequences" title="On-Line Encyclopedia of Integer Sequences">OEIS</a>). Then <i>M</i><sub><i>p</i></sub> is prime if and only if </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msub> <mo>≡<!-- ≡ --></mo> <mn>0</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0952c8b1cba829d16b7e669761f9276f7c988aaa" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:22.155ex; height:3.009ex;" alt="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}"></span></dd></dl> <p>The number <i>s</i><sub><i>p</i> − 2</sub> mod <i>M</i><sub><i>p</i></sub> is called the <b>Lucas–Lehmer residue</b> of <i>p</i>. (Some authors equivalently set <i>s</i><sub>1</sub> = 4 and test <i>s</i><sub><i>p</i>−1</sub> mod <i>M</i><sub><i>p</i></sub>). In <a href="/wiki/Pseudocode" title="Pseudocode">pseudocode</a>, the test might be written as </p> <pre>// Determine if <i>M</i><sub><i>p</i></sub> = 2<sup><i>p</i></sup> − 1 is prime for <i>p</i> > 2 <b>Lucas–Lehmer</b>(p) <b>var</b> s = 4 <b>var</b> M = 2<sup><i>p</i></sup> − 1 <b>repeat</b> p − 2 times: s = ((s × s) − 2) mod M <b>if</b> s == 0 <b>return</b> PRIME <b>else</b> <b>return</b> COMPOSITE </pre> <p>Performing the <code>mod M</code> at each iteration ensures that all intermediate results are at most <i>p</i> bits (otherwise the number of bits would double each iteration). The same strategy is used in <a href="/wiki/Modular_exponentiation" title="Modular exponentiation">modular exponentiation</a>. </p> <div class="mw-heading mw-heading3"><h3 id="Alternate_starting_values">Alternate starting values</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=2" title="Edit section: Alternate starting values"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Starting values <i>s</i><sub>0</sub> other than 4 are possible, for instance 10, 52, and others (sequence <span class="nowrap external"><a href="//oeis.org/A018844" class="extiw" title="oeis:A018844">A018844</a></span> in the <a href="/wiki/On-Line_Encyclopedia_of_Integer_Sequences" title="On-Line Encyclopedia of Integer Sequences">OEIS</a>).<sup id="cite_ref-Jansen_2-0" class="reference"><a href="#cite_note-Jansen-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> The Lucas-Lehmer residue calculated with these alternative starting values will still be zero if <i>M</i><sub><i>p</i></sub> is a Mersenne prime. However, the terms of the sequence will be different and a non-zero Lucas-Lehmer residue for non-prime <i>M</i><sub><i>p</i></sub> will have a different numerical value from the non-zero value calculated when <i>s</i><sub>0</sub> = 4. </p><p>It is also possible to use the starting value (2 mod <i>M</i><sub><i>p</i></sub>)(3 mod <i>M</i><sub><i>p</i></sub>)<sup>−1</sup>, usually denoted by 2/3 for short.<sup id="cite_ref-Jansen_2-1" class="reference"><a href="#cite_note-Jansen-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> This starting value equals (2<sup>p</sup> + 1) /3, the <a href="/wiki/Wagstaff_number" class="mw-redirect" title="Wagstaff number">Wagstaff number</a> with exponent <i>p</i>. </p><p>Starting values like 4, 10, and 2/3 are universal, that is, they are valid for all (or nearly all) <i>p</i>. There are infinitely many additional universal starting values.<sup id="cite_ref-Jansen_2-2" class="reference"><a href="#cite_note-Jansen-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> However, some other starting values are only valid for a subset of all possible <i>p</i>, for example <i>s</i><sub>0</sub> = 3 can be used if <i>p</i> = 3 (mod 4).<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> This starting value was often used where suitable in the era of hand computation, including by Lucas in proving <i>M</i><sub><i>127</i></sub> prime.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> The first few terms of the sequence are 3, 7, 47, ... (sequence <span class="nowrap external"><a href="//oeis.org/A001566" class="extiw" title="oeis:A001566">A001566</a></span> in the <a href="/wiki/On-Line_Encyclopedia_of_Integer_Sequences" title="On-Line Encyclopedia of Integer Sequences">OEIS</a>). </p> <div class="mw-heading mw-heading3"><h3 id="Sign_of_penultimate_term">Sign of penultimate term</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=3" title="Edit section: Sign of penultimate term"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>If <i>s</i><sub><i>p</i>−2</sub> = 0 mod <i>M</i><sub><i>p</i></sub> then the penultimate term is <i>s</i><sub><i>p</i>−3</sub> = ± 2<sup>(<i>p</i>+1)/2</sup> mod <i>M</i><sub><i>p</i></sub>. The sign of this penultimate term is called the Lehmer symbol ϵ(<i>s</i><sub>0</sub>, <i>p</i>). </p><p>In 2000 S.Y. Gebre-Egziabher proved that for the starting value 2/3 and for <i>p</i> ≠ 5 the sign is: </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \epsilon ({2 \over 3},\ p)=(-1)^{p-1 \over 2}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ϵ<!-- ϵ --></mi> <mo stretchy="false">(</mo> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mn>2</mn> <mn>3</mn> </mfrac> </mrow> <mo>,</mo> <mtext> </mtext> <mi>p</mi> <mo stretchy="false">)</mo> <mo>=</mo> <mo stretchy="false">(</mo> <mo>−<!-- − --></mo> <mn>1</mn> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <mi>p</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \epsilon ({2 \over 3},\ p)=(-1)^{p-1 \over 2}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a8181671dfb577980509a70344d0a6a7d23a48da" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:18.859ex; height:5.343ex;" alt="{\displaystyle \epsilon ({2 \over 3},\ p)=(-1)^{p-1 \over 2}}"></span></dd></dl> <p>That is, ϵ(2/3, <i>p</i>) = +1 if <i>p</i> = 1 (mod 4) and p ≠ 5.<sup id="cite_ref-Jansen_2-3" class="reference"><a href="#cite_note-Jansen-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> </p><p>The same author also proved <a href="/wiki/George_Woltman" title="George Woltman">Woltman</a>'s conjecture<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> that the Lehmer symbols for starting values 4 and 10 when <i>p</i> is not 2 or 5 are related by: </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \epsilon (10,\ p)=\epsilon (4,\ p)\ \times \ (-1)^{{(p+1)(p+3)} \over 8}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ϵ<!-- ϵ --></mi> <mo stretchy="false">(</mo> <mn>10</mn> <mo>,</mo> <mtext> </mtext> <mi>p</mi> <mo stretchy="false">)</mo> <mo>=</mo> <mi>ϵ<!-- ϵ --></mi> <mo stretchy="false">(</mo> <mn>4</mn> <mo>,</mo> <mtext> </mtext> <mi>p</mi> <mo stretchy="false">)</mo> <mtext> </mtext> <mo>×<!-- × --></mo> <mtext> </mtext> <mo stretchy="false">(</mo> <mo>−<!-- − --></mo> <mn>1</mn> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">(</mo> <mi>p</mi> <mo>+</mo> <mn>1</mn> <mo stretchy="false">)</mo> <mo stretchy="false">(</mo> <mi>p</mi> <mo>+</mo> <mn>3</mn> <mo stretchy="false">)</mo> </mrow> <mn>8</mn> </mfrac> </mrow> </msup> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \epsilon (10,\ p)=\epsilon (4,\ p)\ \times \ (-1)^{{(p+1)(p+3)} \over 8}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f100265799d09d404e6a8cc7ccb466c7db83f2de" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:34.341ex; height:4.509ex;" alt="{\displaystyle \epsilon (10,\ p)=\epsilon (4,\ p)\ \times \ (-1)^{{(p+1)(p+3)} \over 8}}"></span></dd></dl> <p>That is, ϵ(4, <i>p</i>) × ϵ(10, <i>p</i>) = 1 if <i>p</i> = 5 or 7 (mod 8) and p ≠ 2, 5.<sup id="cite_ref-Jansen_2-4" class="reference"><a href="#cite_note-Jansen-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> </p><p>OEIS sequence <a href="//oeis.org/A123271" class="extiw" title="oeis:A123271">A123271</a> shows ϵ(4, <i>p</i>) for each Mersenne prime <i>M</i><sub><i>p</i></sub>. </p> <div class="mw-heading mw-heading2"><h2 id="Time_complexity">Time complexity</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=4" title="Edit section: Time complexity"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the algorithm as written above, there are two expensive operations during each iteration: the multiplication <code>s × s</code>, and the <code>mod M</code> operation. The <code>mod M</code> operation can be made particularly efficient on standard binary computers by observing that </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle k\equiv (k\,{\bmod {\,}}2^{n})+\lfloor k/2^{n}\rfloor {\pmod {2^{n}-1}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>k</mi> <mo>≡<!-- ≡ --></mo> <mo stretchy="false">(</mo> <mi>k</mi> <mspace width="thinmathspace" /> <mrow class="MJX-TeXAtom-ORD"> <mo lspace="thickmathspace" rspace="thickmathspace">mod</mo> <mrow class="MJX-TeXAtom-ORD"> <mspace width="thinmathspace" /> </mrow> </mrow> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msup> <mo stretchy="false">)</mo> <mo>+</mo> <mo fence="false" stretchy="false">⌊<!-- ⌊ --></mo> <mi>k</mi> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msup> <mo fence="false" stretchy="false">⌋<!-- ⌋ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle k\equiv (k\,{\bmod {\,}}2^{n})+\lfloor k/2^{n}\rfloor {\pmod {2^{n}-1}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/997585237958937ccef13be5365beb96fdce6128" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:42.541ex; height:2.843ex;" alt="{\displaystyle k\equiv (k\,{\bmod {\,}}2^{n})+\lfloor k/2^{n}\rfloor {\pmod {2^{n}-1}}.}"></span></dd></dl> <p>This says that the least significant <i>n</i> bits of <i>k</i> plus the remaining bits of <i>k</i> are equivalent to <i>k</i> modulo 2<sup><i>n</i></sup>−1. This equivalence can be used repeatedly until at most <i>n</i> bits remain. In this way, the remainder after dividing <i>k</i> by the Mersenne number 2<sup><i>n</i></sup>−1 is computed without using division. For example, </p> <table> <tbody><tr> <td>916 mod 2<sup>5</sup>−1</td> <td>=</td> <td>1110010100<sub>2</sub> mod 2<sup>5</sup>−1 </td></tr> <tr> <td></td> <td>=</td> <td>((916 mod 2<sup>5</sup>) + int(916 ÷ 2<sup>5</sup>)) mod 2<sup>5</sup>−1 </td></tr> <tr> <td></td> <td>=</td> <td>(10100<sub>2</sub> + 11100<sub>2</sub>) mod 2<sup>5</sup>−1 </td></tr> <tr> <td></td> <td>=</td> <td>110000<sub>2</sub> mod 2<sup>5</sup>−1 </td></tr> <tr> <td></td> <td>=</td> <td>(10000<sub>2</sub> + 1<sub>2</sub>) mod 2<sup>5</sup>−1 </td></tr> <tr> <td></td> <td>=</td> <td>10001<sub>2</sub> mod 2<sup>5</sup>−1 </td></tr> <tr> <td></td> <td>=</td> <td>10001<sub>2</sub> </td></tr> <tr> <td></td> <td>=</td> <td>17. </td></tr></tbody></table> <p>Moreover, since <code>s × s</code> will never exceed M<sup>2</sup> < 2<sup>2p</sup>, this simple technique converges in at most 1 <i>p</i>-bit addition (and possibly a carry from the <i>p</i>th bit to the 1st bit), which can be done in linear time. This algorithm has a small exceptional case. It will produce 2<sup><i>n</i></sup>−1 for a multiple of the modulus rather than the correct value of 0. However, this case is easy to detect and correct. </p><p>With the modulus out of the way, the asymptotic complexity of the algorithm only depends on the <a href="/wiki/Multiplication_algorithm" title="Multiplication algorithm">multiplication algorithm</a> used to square <i>s</i> at each step. The simple "grade-school" algorithm for multiplication requires <a href="/wiki/Big_O_notation" title="Big O notation">O</a>(<i>p</i><sup>2</sup>) bit-level or word-level operations to square a <i>p</i>-bit number. Since this happens O(<i>p</i>) times, the total time complexity is O(<i>p</i><sup>3</sup>). A more efficient multiplication algorithm is the <a href="/wiki/Sch%C3%B6nhage%E2%80%93Strassen_algorithm" title="Schönhage–Strassen algorithm">Schönhage–Strassen algorithm</a>, which is based on the <a href="/wiki/Fast_Fourier_transform" title="Fast Fourier transform">Fast Fourier transform</a>. It only requires O(<i>p</i> log <i>p</i> log log <i>p</i>) time to square a <i>p</i>-bit number. This reduces the complexity to O(<i>p</i><sup>2</sup> log <i>p</i> log log <i>p</i>) or Õ(<i>p</i><sup>2</sup>).<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> An even more efficient multiplication algorithm, <a href="/wiki/F%C3%BCrer%27s_algorithm" class="mw-redirect" title="Fürer's algorithm">Fürer's algorithm</a>, only needs <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle p\log p\ 2^{O(\log ^{*}p)}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>p</mi> <mi>log</mi> <mo>⁡<!-- --></mo> <mi>p</mi> <mtext> </mtext> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>O</mi> <mo stretchy="false">(</mo> <msup> <mi>log</mi> <mrow class="MJX-TeXAtom-ORD"> <mo>∗<!-- ∗ --></mo> </mrow> </msup> <mo>⁡<!-- --></mo> <mi>p</mi> <mo stretchy="false">)</mo> </mrow> </msup> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle p\log p\ 2^{O(\log ^{*}p)}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/21606c5a27d0ae7a75fb2313ec660c4da725a8e7" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; margin-left: -0.089ex; width:14.83ex; height:3.176ex;" alt="{\displaystyle p\log p\ 2^{O(\log ^{*}p)}}"></span> time to multiply two <i>p</i>-bit numbers. </p><p>By comparison, the most efficient randomized primality test for general integers, the <a href="/wiki/Miller%E2%80%93Rabin_primality_test" title="Miller–Rabin primality test">Miller–Rabin primality test</a>, requires O(<i>k</i> <i>n</i><sup>2</sup> log <i>n</i> log log <i>n</i>)<sup class="noprint Inline-Template" style="white-space:nowrap;">[<i><a href="/wiki/Miller%E2%80%93Rabin_primality_test" title="Miller–Rabin primality test"><span title="This text contradicts material at the article 'Miller–Rabin primality test'.">contradictory</span></a></i>]</sup> bit operations using FFT multiplication for an <i>n</i>-digit number, where <i>k</i> is the number of iterations and is related to the error rate. For constant <i>k</i>, this is in the same complexity class as the Lucas-Lehmer test. In practice however, the cost of doing many iterations and other differences leads to worse performance for Miller–Rabin.<sup class="noprint Inline-Template" style="margin-left:0.1em; white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Please_clarify" title="Wikipedia:Please clarify"><span title="The text near this tag may need clarification or removal of jargon. (September 2022)">clarification needed</span></a></i>]</sup> The most efficient deterministic primality test for any <i>n</i>-digit number, the <a href="/wiki/AKS_primality_test" title="AKS primality test">AKS primality test</a>, requires Õ(n<sup>6</sup>) bit operations in its best known variant and is extremely slow even for relatively small values. </p> <div class="mw-heading mw-heading2"><h2 id="Examples">Examples</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=5" title="Edit section: Examples"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The Mersenne number M<sub>3</sub> = 2<sup>3</sup>−1 = 7 is prime. The Lucas–Lehmer test verifies this as follows. Initially <i>s</i> is set to 4 and then is updated 3−2 = 1 time: </p> <ul><li>s ← ((4 × 4) − 2) mod 7 = 0.</li></ul> <p>Since the final value of <i>s</i> is 0, the conclusion is that M<sub>3</sub> is prime. </p><p>On the other hand, M<sub>11</sub> = 2047 = 23 × 89 is not prime. Again, <i>s</i> is set to 4 but is now updated 11−2 = 9 times: </p> <ul><li>s ← ((4 × 4) − 2) mod 2047 = 14</li> <li>s ← ((14 × 14) − 2) mod 2047 = 194</li> <li>s ← ((194 × 194) − 2) mod 2047 = 788</li> <li>s ← ((788 × 788) − 2) mod 2047 = 701</li> <li>s ← ((701 × 701) − 2) mod 2047 = 119</li> <li>s ← ((119 × 119) − 2) mod 2047 = 1877</li> <li>s ← ((1877 × 1877) − 2) mod 2047 = 240</li> <li>s ← ((240 × 240) − 2) mod 2047 = 282</li> <li>s ← ((282 × 282) − 2) mod 2047 = 1736</li></ul> <p>Since the final value of <i>s</i> is not 0, the conclusion is that M<sub>11</sub> = 2047 is not prime. Although M<sub>11</sub> = 2047 has nontrivial factors, the Lucas–Lehmer test gives no indication about what they might be. </p> <div class="mw-heading mw-heading2"><h2 id="Proof_of_correctness">Proof of correctness</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=6" title="Edit section: Proof of correctness"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The proof of correctness for this test presented here is simpler than the original proof given by Lehmer. Recall the definition </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{i}={\begin{cases}4&{\text{if }}i=0;\\s_{i-1}^{2}-2&{\text{otherwise.}}\end{cases}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> </mrow> </msub> <mo>=</mo> <mrow class="MJX-TeXAtom-ORD"> <mrow> <mo>{</mo> <mtable columnalign="left left" rowspacing=".2em" columnspacing="1em" displaystyle="false"> <mtr> <mtd> <mn>4</mn> </mtd> <mtd> <mrow class="MJX-TeXAtom-ORD"> <mtext>if </mtext> </mrow> <mi>i</mi> <mo>=</mo> <mn>0</mn> <mo>;</mo> </mtd> </mtr> <mtr> <mtd> <msubsup> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msubsup> <mo>−<!-- − --></mo> <mn>2</mn> </mtd> <mtd> <mrow class="MJX-TeXAtom-ORD"> <mtext>otherwise.</mtext> </mrow> </mtd> </mtr> </mtable> <mo fence="true" stretchy="true" symmetric="true"></mo> </mrow> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{i}={\begin{cases}4&{\text{if }}i=0;\\s_{i-1}^{2}-2&{\text{otherwise.}}\end{cases}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4212bd376678838f4f69192f5f498bf3d03c5f67" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.505ex; width:28.023ex; height:6.176ex;" alt="{\displaystyle s_{i}={\begin{cases}4&{\text{if }}i=0;\\s_{i-1}^{2}-2&{\text{otherwise.}}\end{cases}}}"></span></dd></dl> <p>The goal is to show that <i>M</i><sub><i>p</i></sub> is prime <a href="/wiki/Iff" class="mw-redirect" title="Iff">iff</a> <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msub> <mo>≡<!-- ≡ --></mo> <mn>0</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0952c8b1cba829d16b7e669761f9276f7c988aaa" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:22.155ex; height:3.009ex;" alt="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}"></span> </p><p>The sequence <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\langle }s_{i}{\rangle }}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> </mrow> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> </mrow> </msub> <mrow class="MJX-TeXAtom-ORD"> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\langle }s_{i}{\rangle }}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/24e9500c6c336132946bca026091a126fa03aa91" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:3.699ex; height:2.843ex;" alt="{\displaystyle {\langle }s_{i}{\rangle }}"></span> is a <a href="/wiki/Recurrence_relation" title="Recurrence relation">recurrence relation</a> with a <a href="/wiki/Closed-form_solution" class="mw-redirect" title="Closed-form solution">closed-form solution</a>. Let <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega =2+{\sqrt {3}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> <mo>=</mo> <mn>2</mn> <mo>+</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega =2+{\sqrt {3}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/42ad31cdaebbbb24df6687a79cf11d9f68a523c8" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:11.645ex; height:2.843ex;" alt="{\displaystyle \omega =2+{\sqrt {3}}}"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\bar {\omega }}=2-{\sqrt {3}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mo>=</mo> <mn>2</mn> <mo>−<!-- − --></mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\bar {\omega }}=2-{\sqrt {3}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1e347fe3ad60a778168581b7d4713db857febfd8" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:11.645ex; height:2.843ex;" alt="{\displaystyle {\bar {\omega }}=2-{\sqrt {3}}}"></span>. It then follows by <a href="/wiki/Mathematical_induction" title="Mathematical induction">induction</a> that <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{i}=\omega ^{2^{i}}+{\bar {\omega }}^{2^{i}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> </mrow> </msub> <mo>=</mo> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> </mrow> </msup> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>i</mi> </mrow> </msup> </mrow> </msup> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{i}=\omega ^{2^{i}}+{\bar {\omega }}^{2^{i}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/076a6c95f222fb26423231bdfa3ca89d7f76cae8" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:14.079ex; height:3.343ex;" alt="{\displaystyle s_{i}=\omega ^{2^{i}}+{\bar {\omega }}^{2^{i}}}"></span> for all <i>i</i>: </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{0}=\omega ^{2^{0}}+{\bar {\omega }}^{2^{0}}=\left(2+{\sqrt {3}}\right)+\left(2-{\sqrt {3}}\right)=4}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>0</mn> </mrow> </msub> <mo>=</mo> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mn>0</mn> </mrow> </msup> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mn>0</mn> </mrow> </msup> </mrow> </msup> <mo>=</mo> <mrow> <mo>(</mo> <mrow> <mn>2</mn> <mo>+</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mrow> <mo>)</mo> </mrow> <mo>+</mo> <mrow> <mo>(</mo> <mrow> <mn>2</mn> <mo>−<!-- − --></mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mrow> <mo>)</mo> </mrow> <mo>=</mo> <mn>4</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{0}=\omega ^{2^{0}}+{\bar {\omega }}^{2^{0}}=\left(2+{\sqrt {3}}\right)+\left(2-{\sqrt {3}}\right)=4}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/aa8ea8ac41982e16d98c9686a2e4467b2b4d0416" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:43.409ex; height:3.676ex;" alt="{\displaystyle s_{0}=\omega ^{2^{0}}+{\bar {\omega }}^{2^{0}}=\left(2+{\sqrt {3}}\right)+\left(2-{\sqrt {3}}\right)=4}"></span></dd></dl> <p>and </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}s_{n}&=s_{n-1}^{2}-2\\&=\left(\omega ^{2^{n-1}}+{\bar {\omega }}^{2^{n-1}}\right)^{2}-2\\&=\omega ^{2^{n}}+{\bar {\omega }}^{2^{n}}+2(\omega {\bar {\omega }})^{2^{n-1}}-2\\&=\omega ^{2^{n}}+{\bar {\omega }}^{2^{n}}.\end{aligned}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"> <mtr> <mtd> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msub> </mtd> <mtd> <mi></mi> <mo>=</mo> <msubsup> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msubsup> <mo>−<!-- − --></mo> <mn>2</mn> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <msup> <mrow> <mo>(</mo> <mrow> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> </mrow> </msup> </mrow> <mo>)</mo> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>−<!-- − --></mo> <mn>2</mn> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msup> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msup> </mrow> </msup> <mo>+</mo> <mn>2</mn> <mo stretchy="false">(</mo> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> </mrow> </msup> <mo>−<!-- − --></mo> <mn>2</mn> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msup> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>n</mi> </mrow> </msup> </mrow> </msup> <mo>.</mo> </mtd> </mtr> </mtable> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}s_{n}&=s_{n-1}^{2}-2\\&=\left(\omega ^{2^{n-1}}+{\bar {\omega }}^{2^{n-1}}\right)^{2}-2\\&=\omega ^{2^{n}}+{\bar {\omega }}^{2^{n}}+2(\omega {\bar {\omega }})^{2^{n-1}}-2\\&=\omega ^{2^{n}}+{\bar {\omega }}^{2^{n}}.\end{aligned}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/aa21213d7eeed103f8515bf991cafce860eb9c7b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -7.171ex; margin-top: -0.197ex; width:32.36ex; height:15.509ex;" alt="{\displaystyle {\begin{aligned}s_{n}&=s_{n-1}^{2}-2\\&=\left(\omega ^{2^{n-1}}+{\bar {\omega }}^{2^{n-1}}\right)^{2}-2\\&=\omega ^{2^{n}}+{\bar {\omega }}^{2^{n}}+2(\omega {\bar {\omega }})^{2^{n-1}}-2\\&=\omega ^{2^{n}}+{\bar {\omega }}^{2^{n}}.\end{aligned}}}"></span></dd></dl> <p>The last step uses <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega {\bar {\omega }}=\left(2+{\sqrt {3}}\right)\left(2-{\sqrt {3}}\right)=1.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mo>=</mo> <mrow> <mo>(</mo> <mrow> <mn>2</mn> <mo>+</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mrow> <mo>)</mo> </mrow> <mrow> <mo>(</mo> <mrow> <mn>2</mn> <mo>−<!-- − --></mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mrow> <mo>)</mo> </mrow> <mo>=</mo> <mn>1.</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega {\bar {\omega }}=\left(2+{\sqrt {3}}\right)\left(2-{\sqrt {3}}\right)=1.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/28d1eb215dfe2a20072e0f11f9f90f44dcc2a3c1" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:29.747ex; height:3.176ex;" alt="{\displaystyle \omega {\bar {\omega }}=\left(2+{\sqrt {3}}\right)\left(2-{\sqrt {3}}\right)=1.}"></span> This closed form is used in both the proof of sufficiency and the proof of necessity. </p> <div class="mw-heading mw-heading3"><h3 id="Sufficiency">Sufficiency</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=7" title="Edit section: Sufficiency"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The goal is to show that <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msub> <mo>≡<!-- ≡ --></mo> <mn>0</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/692efc35a3bcf316672b6e0f8c456b66010018eb" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:21.508ex; height:3.009ex;" alt="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}}"></span> implies that <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4a8004b0c032f7742153c5994fb87d923fdb4493" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.313ex; height:2.843ex;" alt="{\displaystyle M_{p}}"></span> is prime. What follows is a straightforward proof exploiting elementary <a href="/wiki/Group_theory" title="Group theory">group theory</a> given by J. W. Bruce<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> as related by Jason Wojciechowski.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> </p><p>Suppose <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msub> <mo>≡<!-- ≡ --></mo> <mn>0</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0952c8b1cba829d16b7e669761f9276f7c988aaa" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:22.155ex; height:3.009ex;" alt="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}.}"></span> Then </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p-2}}+{\bar {\omega }}^{2^{p-2}}=kM_{p}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>=</mo> <mi>k</mi> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p-2}}+{\bar {\omega }}^{2^{p-2}}=kM_{p}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1ecccd60817ae81a05bb111a86c91919b5916557" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:20.545ex; height:3.676ex;" alt="{\displaystyle \omega ^{2^{p-2}}+{\bar {\omega }}^{2^{p-2}}=kM_{p}}"></span></dd></dl> <p>for some integer <i>k</i>, so </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p-2}}=kM_{p}-{\bar {\omega }}^{2^{p-2}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>=</mo> <mi>k</mi> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p-2}}=kM_{p}-{\bar {\omega }}^{2^{p-2}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1a82ca1a36bb6c12a7002b4df3edbade3929412c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:21.192ex; height:3.676ex;" alt="{\displaystyle \omega ^{2^{p-2}}=kM_{p}-{\bar {\omega }}^{2^{p-2}}.}"></span></dd></dl> <p>Multiplying by <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p-2}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p-2}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/12aeced51a688d848deb8b00e295e57746b93c6f" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.041ex; height:3.009ex;" alt="{\displaystyle \omega ^{2^{p-2}}}"></span> gives </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \left(\omega ^{2^{p-2}}\right)^{2}=kM_{p}\omega ^{2^{p-2}}-(\omega {\bar {\omega }})^{2^{p-2}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mrow> <mo>(</mo> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>)</mo> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>=</mo> <mi>k</mi> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>−<!-- − --></mo> <mo stretchy="false">(</mo> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \left(\omega ^{2^{p-2}}\right)^{2}=kM_{p}\omega ^{2^{p-2}}-(\omega {\bar {\omega }})^{2^{p-2}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d9e64f3bd6895fe5ed4593848b88fe013b951c2f" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:33.318ex; height:5.176ex;" alt="{\displaystyle \left(\omega ^{2^{p-2}}\right)^{2}=kM_{p}\omega ^{2^{p-2}}-(\omega {\bar {\omega }})^{2^{p-2}}.}"></span></dd></dl> <p>Thus, </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p-1}}=kM_{p}\omega ^{2^{p-2}}-1.\qquad \qquad (1)}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> </mrow> </msup> <mo>=</mo> <mi>k</mi> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1.</mn> <mspace width="2em" /> <mspace width="2em" /> <mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p-1}}=kM_{p}\omega ^{2^{p-2}}-1.\qquad \qquad (1)}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/11bf6306d9d9251a5811dcb27ca886a387c47d5d" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:34.617ex; height:3.676ex;" alt="{\displaystyle \omega ^{2^{p-1}}=kM_{p}\omega ^{2^{p-2}}-1.\qquad \qquad (1)}"></span></dd></dl> <p>For a contradiction, suppose <i>M</i><sub><i>p</i></sub> is composite, and let <i>q</i> be the smallest prime factor of <i>M</i><sub><i>p</i></sub>. Mersenne numbers are odd, so <i>q</i> > 2. Let <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathbb {Z} _{q}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>q</mi> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \mathbb {Z} _{q}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/95957439e9ed316d6c41785fbcc8c33a28dfe5a5" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:2.539ex; height:2.843ex;" alt="{\displaystyle \mathbb {Z} _{q}}"></span> be the integers modulo <i>q</i>, and let <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle X=\left\{a+b{\sqrt {3}}\mid a,b\in \mathbb {Z} _{q}\right\}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>X</mi> <mo>=</mo> <mrow> <mo>{</mo> <mrow> <mi>a</mi> <mo>+</mo> <mi>b</mi> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> <mo>∣<!-- ∣ --></mo> <mi>a</mi> <mo>,</mo> <mi>b</mi> <mo>∈<!-- ∈ --></mo> <msub> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>q</mi> </mrow> </msub> </mrow> <mo>}</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle X=\left\{a+b{\sqrt {3}}\mid a,b\in \mathbb {Z} _{q}\right\}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/40507e204dc0b2b1960cf5e9c222f4909a860678" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:27.567ex; height:3.176ex;" alt="{\displaystyle X=\left\{a+b{\sqrt {3}}\mid a,b\in \mathbb {Z} _{q}\right\}.}"></span> Multiplication in <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle X}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>X</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle X}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/68baa052181f707c662844a465bfeeb135e82bab" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.98ex; height:2.176ex;" alt="{\displaystyle X}"></span> is defined as </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \left(a+{\sqrt {3}}b\right)\left(c+{\sqrt {3}}d\right)=[(ac+3bd)\,{\bmod {\,}}q]+{\sqrt {3}}[(ad+bc)\,{\bmod {\,}}q].}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow> <mo>(</mo> <mrow> <mi>a</mi> <mo>+</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> <mi>b</mi> </mrow> <mo>)</mo> </mrow> <mrow> <mo>(</mo> <mrow> <mi>c</mi> <mo>+</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> <mi>d</mi> </mrow> <mo>)</mo> </mrow> <mo>=</mo> <mo stretchy="false">[</mo> <mo stretchy="false">(</mo> <mi>a</mi> <mi>c</mi> <mo>+</mo> <mn>3</mn> <mi>b</mi> <mi>d</mi> <mo stretchy="false">)</mo> <mspace width="thinmathspace" /> <mrow class="MJX-TeXAtom-ORD"> <mo lspace="thickmathspace" rspace="thickmathspace">mod</mo> <mrow class="MJX-TeXAtom-ORD"> <mspace width="thinmathspace" /> </mrow> </mrow> <mi>q</mi> <mo stretchy="false">]</mo> <mo>+</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> <mo stretchy="false">[</mo> <mo stretchy="false">(</mo> <mi>a</mi> <mi>d</mi> <mo>+</mo> <mi>b</mi> <mi>c</mi> <mo stretchy="false">)</mo> <mspace width="thinmathspace" /> <mrow class="MJX-TeXAtom-ORD"> <mo lspace="thickmathspace" rspace="thickmathspace">mod</mo> <mrow class="MJX-TeXAtom-ORD"> <mspace width="thinmathspace" /> </mrow> </mrow> <mi>q</mi> <mo stretchy="false">]</mo> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \left(a+{\sqrt {3}}b\right)\left(c+{\sqrt {3}}d\right)=[(ac+3bd)\,{\bmod {\,}}q]+{\sqrt {3}}[(ad+bc)\,{\bmod {\,}}q].}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d76ce265aa57d35a1bb12154299692d8f82cbf5b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:67.658ex; height:3.176ex;" alt="{\displaystyle \left(a+{\sqrt {3}}b\right)\left(c+{\sqrt {3}}d\right)=[(ac+3bd)\,{\bmod {\,}}q]+{\sqrt {3}}[(ad+bc)\,{\bmod {\,}}q].}"></span><sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>note 1<span class="cite-bracket">]</span></a></sup></dd></dl> <p>Clearly, this multiplication is closed, i.e. the product of numbers from <i>X</i> is itself in <i>X</i>. The size of <i>X</i> is denoted by <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |X|.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <mi>X</mi> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle |X|.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/e6f76b8556823ce66b8657183123fe0742f744ee" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:3.921ex; height:2.843ex;" alt="{\displaystyle |X|.}"></span> </p><p>Since <i>q</i> > 2, it follows that <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/48eff443f9de7a985bb94ca3bde20813ea737be8" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.446ex; height:1.676ex;" alt="{\displaystyle \omega }"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\bar {\omega }}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\bar {\omega }}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4c53181fa3ce2b060f199a67a4bfd2d66277ef6c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.446ex; height:2.009ex;" alt="{\displaystyle {\bar {\omega }}}"></span> are in <i>X</i>.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>note 2<span class="cite-bracket">]</span></a></sup> The subset of elements in <i>X</i> with inverses forms a group, which is denoted by <i>X</i>* and has size <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |X^{*}|.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <msup> <mi>X</mi> <mrow class="MJX-TeXAtom-ORD"> <mo>∗<!-- ∗ --></mo> </mrow> </msup> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle |X^{*}|.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/42d762ab8acf22524a810e5c9a2900175b53d1f1" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:4.992ex; height:2.843ex;" alt="{\displaystyle |X^{*}|.}"></span> One element in <i>X</i> that does not have an inverse is 0, so <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |X^{*}|\leq |X|-1=q^{2}-1.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <msup> <mi>X</mi> <mrow class="MJX-TeXAtom-ORD"> <mo>∗<!-- ∗ --></mo> </mrow> </msup> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <mo>≤<!-- ≤ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <mi>X</mi> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <mo>−<!-- − --></mo> <mn>1</mn> <mo>=</mo> <msup> <mi>q</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1.</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle |X^{*}|\leq |X|-1=q^{2}-1.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/771a8a530d1d4db13ddf3e7af2270e825d984927" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:24.602ex; height:3.176ex;" alt="{\displaystyle |X^{*}|\leq |X|-1=q^{2}-1.}"></span> </p><p>Now <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}\equiv 0{\pmod {q}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>≡<!-- ≡ --></mo> <mn>0</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <mi>q</mi> <mo stretchy="false">)</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}\equiv 0{\pmod {q}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4f1bf27e31fdbfde63f8015431279e634761b516" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:18.328ex; height:3.009ex;" alt="{\displaystyle M_{p}\equiv 0{\pmod {q}}}"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega \in X}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> <mo>∈<!-- ∈ --></mo> <mi>X</mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega \in X}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/03afa58d12fdf0d1a078879d44fa377a1aa37ead" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:6.266ex; height:2.176ex;" alt="{\displaystyle \omega \in X}"></span>, so </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle kM_{p}\omega ^{2^{p-2}}=0}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>k</mi> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>=</mo> <mn>0</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle kM_{p}\omega ^{2^{p-2}}=0}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/46d435810ae4264eee503942d21fd243a57f1b43" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:13.826ex; height:3.676ex;" alt="{\displaystyle kM_{p}\omega ^{2^{p-2}}=0}"></span></dd></dl> <p>in <i>X</i>. Then by equation (1), </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p-1}}=-1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> </mrow> </msup> <mo>=</mo> <mo>−<!-- − --></mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p-1}}=-1}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4b9bff3b9bd0b9aef9112eb3c2e42beebf90c4ef" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:11.11ex; height:3.176ex;" alt="{\displaystyle \omega ^{2^{p-1}}=-1}"></span></dd></dl> <p>in <i>X</i>, and squaring both sides gives </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p}}=1.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> </mrow> </msup> <mo>=</mo> <mn>1.</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p}}=1.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/24adc2cdb859d74b17e4b127c2445eeb819c0f6c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:8.243ex; height:2.676ex;" alt="{\displaystyle \omega ^{2^{p}}=1.}"></span></dd></dl> <p>Thus <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/48eff443f9de7a985bb94ca3bde20813ea737be8" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.446ex; height:1.676ex;" alt="{\displaystyle \omega }"></span> lies in <i>X</i>* and has inverse <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p}-1}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p}-1}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/11b2cd55f85a884a558265c66d0d8d618bc0e739" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:6.083ex; height:2.676ex;" alt="{\displaystyle \omega ^{2^{p}-1}.}"></span> Furthermore, the <a href="/wiki/Order_(group_theory)" title="Order (group theory)">order</a> of <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/48eff443f9de7a985bb94ca3bde20813ea737be8" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.446ex; height:1.676ex;" alt="{\displaystyle \omega }"></span> divides <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{p}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{p}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/386b27e7e7d37a7cf1f35e103b6316ed37213aa3" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.868ex; height:2.343ex;" alt="{\displaystyle 2^{p}.}"></span> However <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{2^{p-1}}\neq 1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> </mrow> </msup> <mo>≠<!-- ≠ --></mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{2^{p-1}}\neq 1}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f13f97ddebfc83b9596edc9286aa699150f2f28d" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:9.302ex; height:3.509ex;" alt="{\displaystyle \omega ^{2^{p-1}}\neq 1}"></span>, so the order does not divide <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{p-1}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> </msup> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{p-1}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5c8481d1bca30db90a71bf52fcd351a4a8c8d3df" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:4.969ex; height:2.676ex;" alt="{\displaystyle 2^{p-1}.}"></span> Thus, the order is exactly <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{p}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{p}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/386b27e7e7d37a7cf1f35e103b6316ed37213aa3" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:2.868ex; height:2.343ex;" alt="{\displaystyle 2^{p}.}"></span> </p><p>The order of an element is at most the order (size) of the group, so </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{p}\leq |X^{*}|\leq q^{2}-1<q^{2}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>≤<!-- ≤ --></mo> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <msup> <mi>X</mi> <mrow class="MJX-TeXAtom-ORD"> <mo>∗<!-- ∗ --></mo> </mrow> </msup> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <mo>≤<!-- ≤ --></mo> <msup> <mi>q</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1</mn> <mo><</mo> <msup> <mi>q</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{p}\leq |X^{*}|\leq q^{2}-1<q^{2}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/bae8c85df7be62f85967a99478c3e3be2d4e592d" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:24.779ex; height:3.176ex;" alt="{\displaystyle 2^{p}\leq |X^{*}|\leq q^{2}-1<q^{2}.}"></span></dd></dl> <p>But <i>q</i> is the smallest prime factor of the composite <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4a8004b0c032f7742153c5994fb87d923fdb4493" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.313ex; height:2.843ex;" alt="{\displaystyle M_{p}}"></span>, so </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle q^{2}\leq M_{p}=2^{p}-1.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>q</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>≤<!-- ≤ --></mo> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>=</mo> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1.</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle q^{2}\leq M_{p}=2^{p}-1.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d17ac9907a5e6dc9b01f0109c38cca3d6e01f376" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:18.515ex; height:3.343ex;" alt="{\displaystyle q^{2}\leq M_{p}=2^{p}-1.}"></span></dd></dl> <p>This yields the contradiction <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{p}<2^{p}-1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo><</mo> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{p}<2^{p}-1}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f748a7175332e9cecf0d0f6c281069880a4def73" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:11.545ex; height:2.509ex;" alt="{\displaystyle 2^{p}<2^{p}-1}"></span>. Therefore, <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4a8004b0c032f7742153c5994fb87d923fdb4493" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.313ex; height:2.843ex;" alt="{\displaystyle M_{p}}"></span> is prime. </p> <div class="mw-heading mw-heading3"><h3 id="Necessity">Necessity</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=8" title="Edit section: Necessity"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the other direction, the goal is to show that the primality of <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4a8004b0c032f7742153c5994fb87d923fdb4493" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.313ex; height:2.843ex;" alt="{\displaystyle M_{p}}"></span> implies <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msub> <mo>≡<!-- ≡ --></mo> <mn>0</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/692efc35a3bcf316672b6e0f8c456b66010018eb" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:21.508ex; height:3.009ex;" alt="{\displaystyle s_{p-2}\equiv 0{\pmod {M_{p}}}}"></span>. The following simplified proof is by Öystein J. Rödseth.<sup id="cite_ref-Rodseth_11-0" class="reference"><a href="#cite_note-Rodseth-11"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> </p><p>Since <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{p}-1\equiv 7{\pmod {12}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1</mn> <mo>≡<!-- ≡ --></mo> <mn>7</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <mn>12</mn> <mo stretchy="false">)</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{p}-1\equiv 7{\pmod {12}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/2330bc7c6b4bf65ec27560278843a1a630abe57f" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:22.494ex; height:2.843ex;" alt="{\displaystyle 2^{p}-1\equiv 7{\pmod {12}}}"></span> for odd <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle p>1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>p</mi> <mo>></mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle p>1}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0f127e7a5f2449ddf3edb8164c2d2439120641f9" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; margin-left: -0.089ex; width:5.52ex; height:2.509ex;" alt="{\displaystyle p>1}"></span>, it follows from <a href="/wiki/Legendre_symbol#Properties_of_the_Legendre_symbol" title="Legendre symbol">properties of the Legendre symbol</a> that <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (3|M_{p})=-1.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mn>3</mn> <mrow class="MJX-TeXAtom-ORD"> <mo stretchy="false">|</mo> </mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> <mo>=</mo> <mo>−<!-- − --></mo> <mn>1.</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (3|M_{p})=-1.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/ccd9e61e1113913d924e7b0ca784c33d36e2980a" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:13.648ex; height:3.009ex;" alt="{\displaystyle (3|M_{p})=-1.}"></span> This means that 3 is a <a href="/wiki/Quadratic_nonresidue" class="mw-redirect" title="Quadratic nonresidue">quadratic nonresidue</a> modulo <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/92c6678fb6a6861a85113a54da3292c03da6c426" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.96ex; height:2.843ex;" alt="{\displaystyle M_{p}.}"></span> By <a href="/wiki/Euler%27s_criterion" title="Euler's criterion">Euler's criterion</a>, this is equivalent to </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 3^{\frac {M_{p}-1}{2}}\equiv -1{\pmod {M_{p}}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>3</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <mo>≡<!-- ≡ --></mo> <mo>−<!-- − --></mo> <mn>1</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 3^{\frac {M_{p}-1}{2}}\equiv -1{\pmod {M_{p}}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f10cf2582e7bbc35e6a8bd8f1451755512a58aa9" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:25.748ex; height:4.676ex;" alt="{\displaystyle 3^{\frac {M_{p}-1}{2}}\equiv -1{\pmod {M_{p}}}.}"></span></dd></dl> <p>In contrast, 2 is a <a href="/wiki/Quadratic_residue" title="Quadratic residue">quadratic residue</a> modulo <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4a8004b0c032f7742153c5994fb87d923fdb4493" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.313ex; height:2.843ex;" alt="{\displaystyle M_{p}}"></span> since <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{p}\equiv 1{\pmod {M_{p}}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>≡<!-- ≡ --></mo> <mn>1</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{p}\equiv 1{\pmod {M_{p}}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/72cee3f3db410924f42d9b84a0899581910c78d4" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:19.48ex; height:3.009ex;" alt="{\displaystyle 2^{p}\equiv 1{\pmod {M_{p}}}}"></span> and so <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2\equiv 2^{p+1}=\left(2^{\frac {p+1}{2}}\right)^{2}{\pmod {M_{p}}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mn>2</mn> <mo>≡<!-- ≡ --></mo> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>+</mo> <mn>1</mn> </mrow> </msup> <mo>=</mo> <msup> <mrow> <mo>(</mo> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <mi>p</mi> <mo>+</mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <mo>)</mo> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2\equiv 2^{p+1}=\left(2^{\frac {p+1}{2}}\right)^{2}{\pmod {M_{p}}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/639ca132ddc9f0b2242f77d5e736755d3608421b" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.505ex; width:34.409ex; height:6.509ex;" alt="{\displaystyle 2\equiv 2^{p+1}=\left(2^{\frac {p+1}{2}}\right)^{2}{\pmod {M_{p}}}.}"></span> This time, Euler's criterion gives </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2^{\frac {M_{p}-1}{2}}\equiv 1{\pmod {M_{p}}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <mo>≡<!-- ≡ --></mo> <mn>1</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 2^{\frac {M_{p}-1}{2}}\equiv 1{\pmod {M_{p}}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d581419c892c7b88c96be59483556a2eb29e5cd5" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:23.94ex; height:4.676ex;" alt="{\displaystyle 2^{\frac {M_{p}-1}{2}}\equiv 1{\pmod {M_{p}}}.}"></span></dd></dl> <p>Combining these two equivalence relations yields </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 24^{\frac {M_{p}-1}{2}}\equiv \left(2^{\frac {M_{p}-1}{2}}\right)^{3}\left(3^{\frac {M_{p}-1}{2}}\right)\equiv (1)^{3}(-1)\equiv -1{\pmod {M_{p}}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mn>24</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <mo>≡<!-- ≡ --></mo> <msup> <mrow> <mo>(</mo> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <mo>)</mo> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mn>3</mn> </mrow> </msup> <mrow> <mo>(</mo> <msup> <mn>3</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <mo>)</mo> </mrow> <mo>≡<!-- ≡ --></mo> <mo stretchy="false">(</mo> <mn>1</mn> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <mn>3</mn> </mrow> </msup> <mo stretchy="false">(</mo> <mo>−<!-- − --></mo> <mn>1</mn> <mo stretchy="false">)</mo> <mo>≡<!-- ≡ --></mo> <mo>−<!-- − --></mo> <mn>1</mn> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle 24^{\frac {M_{p}-1}{2}}\equiv \left(2^{\frac {M_{p}-1}{2}}\right)^{3}\left(3^{\frac {M_{p}-1}{2}}\right)\equiv (1)^{3}(-1)\equiv -1{\pmod {M_{p}}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/952171a3ad86a3de534dc9f109def1fb31e79f9d" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.505ex; width:62.267ex; height:6.676ex;" alt="{\displaystyle 24^{\frac {M_{p}-1}{2}}\equiv \left(2^{\frac {M_{p}-1}{2}}\right)^{3}\left(3^{\frac {M_{p}-1}{2}}\right)\equiv (1)^{3}(-1)\equiv -1{\pmod {M_{p}}}.}"></span></dd></dl> <p>Let <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sigma =2{\sqrt {3}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>σ<!-- σ --></mi> <mo>=</mo> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sigma =2{\sqrt {3}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/33147458c897eb89ec76fbb744c6c0e5145d8d28" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:8.689ex; height:2.843ex;" alt="{\displaystyle \sigma =2{\sqrt {3}}}"></span>, and define <i>X</i> as before as the ring <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle X=\{a+b{\sqrt {3}}\mid a,b\in \mathbb {Z} _{M_{p}}\}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>X</mi> <mo>=</mo> <mo fence="false" stretchy="false">{</mo> <mi>a</mi> <mo>+</mo> <mi>b</mi> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> <mo>∣<!-- ∣ --></mo> <mi>a</mi> <mo>,</mo> <mi>b</mi> <mo>∈<!-- ∈ --></mo> <msub> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msub> <mo fence="false" stretchy="false">}</mo> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle X=\{a+b{\sqrt {3}}\mid a,b\in \mathbb {Z} _{M_{p}}\}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1512269ffa13b930509ca30fdfd644143f5cf6da" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.171ex; width:28.467ex; height:3.343ex;" alt="{\displaystyle X=\{a+b{\sqrt {3}}\mid a,b\in \mathbb {Z} _{M_{p}}\}.}"></span> Then in the ring <i>X</i>, it follows that </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}(6+\sigma )^{M_{p}}&=6^{M_{p}}+\left(2^{M_{p}}\right)\left({\sqrt {3}}^{M_{p}}\right)\\&=6+2\left(3^{\frac {M_{p}-1}{2}}\right){\sqrt {3}}\\&=6+2(-1){\sqrt {3}}\\&=6-\sigma ,\end{aligned}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"> <mtr> <mtd> <mo stretchy="false">(</mo> <mn>6</mn> <mo>+</mo> <mi>σ<!-- σ --></mi> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> </mtd> <mtd> <mi></mi> <mo>=</mo> <msup> <mn>6</mn> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> <mo>+</mo> <mrow> <mo>(</mo> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> <mo>)</mo> </mrow> <mrow> <mo>(</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <mn>6</mn> <mo>+</mo> <mn>2</mn> <mrow> <mo>(</mo> <msup> <mn>3</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <mo>)</mo> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <mn>6</mn> <mo>+</mo> <mn>2</mn> <mo stretchy="false">(</mo> <mo>−<!-- − --></mo> <mn>1</mn> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <mn>6</mn> <mo>−<!-- − --></mo> <mi>σ<!-- σ --></mi> <mo>,</mo> </mtd> </mtr> </mtable> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}(6+\sigma )^{M_{p}}&=6^{M_{p}}+\left(2^{M_{p}}\right)\left({\sqrt {3}}^{M_{p}}\right)\\&=6+2\left(3^{\frac {M_{p}-1}{2}}\right){\sqrt {3}}\\&=6+2(-1){\sqrt {3}}\\&=6-\sigma ,\end{aligned}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/6b6f7847cab50d7cbc88977ddf38199c1f488a05" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -8.005ex; width:35.195ex; height:17.176ex;" alt="{\displaystyle {\begin{aligned}(6+\sigma )^{M_{p}}&=6^{M_{p}}+\left(2^{M_{p}}\right)\left({\sqrt {3}}^{M_{p}}\right)\\&=6+2\left(3^{\frac {M_{p}-1}{2}}\right){\sqrt {3}}\\&=6+2(-1){\sqrt {3}}\\&=6-\sigma ,\end{aligned}}}"></span></dd></dl> <p>where the first equality uses the <a href="/wiki/Proofs_of_Fermat%27s_little_theorem#Proofs_using_the_binomial_theorem" title="Proofs of Fermat's little theorem">Binomial Theorem in a finite field</a>, which is </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (x+y)^{M_{p}}\equiv x^{M_{p}}+y^{M_{p}}{\pmod {M_{p}}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mo stretchy="false">(</mo> <mi>x</mi> <mo>+</mo> <mi>y</mi> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> <mo>≡<!-- ≡ --></mo> <msup> <mi>x</mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> <mo>+</mo> <msup> <mi>y</mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle (x+y)^{M_{p}}\equiv x^{M_{p}}+y^{M_{p}}{\pmod {M_{p}}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/201dfd84053e5e181725159e9c9dc472c27668a6" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:36.546ex; height:3.343ex;" alt="{\displaystyle (x+y)^{M_{p}}\equiv x^{M_{p}}+y^{M_{p}}{\pmod {M_{p}}}}"></span>,</dd></dl> <p>and the second equality uses <a href="/wiki/Fermat%27s_little_theorem" title="Fermat's little theorem">Fermat's little theorem</a>, which is </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a^{M_{p}}\equiv a{\pmod {M_{p}}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>a</mi> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> <mo>≡<!-- ≡ --></mo> <mi>a</mi> <mrow class="MJX-TeXAtom-ORD"> <mspace width="1em" /> <mo stretchy="false">(</mo> <mi>mod</mi> <mspace width="0.333em" /> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo stretchy="false">)</mo> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle a^{M_{p}}\equiv a{\pmod {M_{p}}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0bf4c4d54cefab92adb2e98a7489f76529e99729" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:21.217ex; height:3.343ex;" alt="{\displaystyle a^{M_{p}}\equiv a{\pmod {M_{p}}}}"></span></dd></dl> <p>for any integer <i>a</i>. The value of <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sigma }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>σ<!-- σ --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \sigma }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/59f59b7c3e6fdb1d0365a494b81fb9a696138c36" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle \sigma }"></span> was chosen so that <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ={\frac {(6+\sigma )^{2}}{24}}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> <mo>=</mo> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <mo stretchy="false">(</mo> <mn>6</mn> <mo>+</mo> <mi>σ<!-- σ --></mi> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> </mrow> <mn>24</mn> </mfrac> </mrow> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ={\frac {(6+\sigma )^{2}}{24}}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/028a494051cddf6a44ce76994e851ead5ed40827" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.838ex; width:14.223ex; height:5.843ex;" alt="{\displaystyle \omega ={\frac {(6+\sigma )^{2}}{24}}.}"></span> Consequently, this can be used to compute <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega ^{\frac {M_{p}+1}{2}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega ^{\frac {M_{p}+1}{2}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d2e14b785fe1cdfe97d6ee42a06fdae1b90720a6" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:6.318ex; height:4.009ex;" alt="{\displaystyle \omega ^{\frac {M_{p}+1}{2}}}"></span> in the ring <i>X</i> as </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}\omega ^{\frac {M_{p}+1}{2}}&={\frac {(6+\sigma )^{M_{p}+1}}{24^{\frac {M_{p}+1}{2}}}}\\&={\frac {(6+\sigma )(6+\sigma )^{M_{p}}}{24\cdot 24^{\frac {M_{p}-1}{2}}}}\\&={\frac {(6+\sigma )(6-\sigma )}{-24}}\\&=-1.\end{aligned}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"> <mtr> <mtd> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> </mtd> <mtd> <mi></mi> <mo>=</mo> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <mo stretchy="false">(</mo> <mn>6</mn> <mo>+</mo> <mi>σ<!-- σ --></mi> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> </msup> </mrow> <msup> <mn>24</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> </mfrac> </mrow> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <mo stretchy="false">(</mo> <mn>6</mn> <mo>+</mo> <mi>σ<!-- σ --></mi> <mo stretchy="false">)</mo> <mo stretchy="false">(</mo> <mn>6</mn> <mo>+</mo> <mi>σ<!-- σ --></mi> <msup> <mo stretchy="false">)</mo> <mrow class="MJX-TeXAtom-ORD"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> </mrow> </msup> </mrow> <mrow> <mn>24</mn> <mo>⋅<!-- ⋅ --></mo> <msup> <mn>24</mn> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>−<!-- − --></mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> </mrow> </mfrac> </mrow> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <mo stretchy="false">(</mo> <mn>6</mn> <mo>+</mo> <mi>σ<!-- σ --></mi> <mo stretchy="false">)</mo> <mo stretchy="false">(</mo> <mn>6</mn> <mo>−<!-- − --></mo> <mi>σ<!-- σ --></mi> <mo stretchy="false">)</mo> </mrow> <mrow> <mo>−<!-- − --></mo> <mn>24</mn> </mrow> </mfrac> </mrow> </mtd> </mtr> <mtr> <mtd /> <mtd> <mi></mi> <mo>=</mo> <mo>−<!-- − --></mo> <mn>1.</mn> </mtd> </mtr> </mtable> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}\omega ^{\frac {M_{p}+1}{2}}&={\frac {(6+\sigma )^{M_{p}+1}}{24^{\frac {M_{p}+1}{2}}}}\\&={\frac {(6+\sigma )(6+\sigma )^{M_{p}}}{24\cdot 24^{\frac {M_{p}-1}{2}}}}\\&={\frac {(6+\sigma )(6-\sigma )}{-24}}\\&=-1.\end{aligned}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/52989cf8a6969ca8a161542d14ea4b819f08fcba" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -11.838ex; width:27.95ex; height:24.843ex;" alt="{\displaystyle {\begin{aligned}\omega ^{\frac {M_{p}+1}{2}}&={\frac {(6+\sigma )^{M_{p}+1}}{24^{\frac {M_{p}+1}{2}}}}\\&={\frac {(6+\sigma )(6+\sigma )^{M_{p}}}{24\cdot 24^{\frac {M_{p}-1}{2}}}}\\&={\frac {(6+\sigma )(6-\sigma )}{-24}}\\&=-1.\end{aligned}}}"></span></dd></dl> <p>All that remains is to multiply both sides of this equation by <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\bar {\omega }}^{\frac {M_{p}+1}{4}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>4</mn> </mfrac> </mrow> </msup> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\bar {\omega }}^{\frac {M_{p}+1}{4}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/16a89ddcbdb4f13c4cf22e84dabe720055696b62" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:6.318ex; height:4.009ex;" alt="{\displaystyle {\bar {\omega }}^{\frac {M_{p}+1}{4}}}"></span> and use <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega {\bar {\omega }}=1}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mo>=</mo> <mn>1</mn> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega {\bar {\omega }}=1}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/f529b79a83a18f3af52ccb4da859b256372828cd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:7.153ex; height:2.176ex;" alt="{\displaystyle \omega {\bar {\omega }}=1}"></span>, which gives </p> <dl><dd><span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{aligned}\omega ^{\frac {M_{p}+1}{2}}{\bar {\omega }}^{\frac {M_{p}+1}{4}}&=-{\bar {\omega }}^{\frac {M_{p}+1}{4}}\\\omega ^{\frac {M_{p}+1}{4}}+{\bar {\omega }}^{\frac {M_{p}+1}{4}}&=0\\\omega ^{\frac {2^{p}-1+1}{4}}+{\bar {\omega }}^{\frac {2^{p}-1+1}{4}}&=0\\\omega ^{2^{p-2}}+{\bar {\omega }}^{2^{p-2}}&=0\\s_{p-2}&=0.\end{aligned}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"> <mtr> <mtd> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>2</mn> </mfrac> </mrow> </msup> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>4</mn> </mfrac> </mrow> </msup> </mtd> <mtd> <mi></mi> <mo>=</mo> <mo>−<!-- − --></mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>4</mn> </mfrac> </mrow> </msup> </mtd> </mtr> <mtr> <mtd> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>4</mn> </mfrac> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>+</mo> <mn>1</mn> </mrow> <mn>4</mn> </mfrac> </mrow> </msup> </mtd> <mtd> <mi></mi> <mo>=</mo> <mn>0</mn> </mtd> </mtr> <mtr> <mtd> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1</mn> <mo>+</mo> <mn>1</mn> </mrow> <mn>4</mn> </mfrac> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mfrac> <mrow> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msup> <mo>−<!-- − --></mo> <mn>1</mn> <mo>+</mo> <mn>1</mn> </mrow> <mn>4</mn> </mfrac> </mrow> </msup> </mtd> <mtd> <mi></mi> <mo>=</mo> <mn>0</mn> </mtd> </mtr> <mtr> <mtd> <msup> <mi>ω<!-- ω --></mi> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> <mo>+</mo> <msup> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mrow class="MJX-TeXAtom-ORD"> <msup> <mn>2</mn> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msup> </mrow> </msup> </mtd> <mtd> <mi></mi> <mo>=</mo> <mn>0</mn> </mtd> </mtr> <mtr> <mtd> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msub> </mtd> <mtd> <mi></mi> <mo>=</mo> <mn>0.</mn> </mtd> </mtr> </mtable> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\begin{aligned}\omega ^{\frac {M_{p}+1}{2}}{\bar {\omega }}^{\frac {M_{p}+1}{4}}&=-{\bar {\omega }}^{\frac {M_{p}+1}{4}}\\\omega ^{\frac {M_{p}+1}{4}}+{\bar {\omega }}^{\frac {M_{p}+1}{4}}&=0\\\omega ^{\frac {2^{p}-1+1}{4}}+{\bar {\omega }}^{\frac {2^{p}-1+1}{4}}&=0\\\omega ^{2^{p-2}}+{\bar {\omega }}^{2^{p-2}}&=0\\s_{p-2}&=0.\end{aligned}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/b3bbbe7012eda85561cf5baa566b1a5b219c946d" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -9.505ex; width:29.61ex; height:20.176ex;" alt="{\displaystyle {\begin{aligned}\omega ^{\frac {M_{p}+1}{2}}{\bar {\omega }}^{\frac {M_{p}+1}{4}}&=-{\bar {\omega }}^{\frac {M_{p}+1}{4}}\\\omega ^{\frac {M_{p}+1}{4}}+{\bar {\omega }}^{\frac {M_{p}+1}{4}}&=0\\\omega ^{\frac {2^{p}-1+1}{4}}+{\bar {\omega }}^{\frac {2^{p}-1+1}{4}}&=0\\\omega ^{2^{p-2}}+{\bar {\omega }}^{2^{p-2}}&=0\\s_{p-2}&=0.\end{aligned}}}"></span></dd></dl> <p>Since <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s_{p-2}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>s</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> <mo>−<!-- − --></mo> <mn>2</mn> </mrow> </msub> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle s_{p-2}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/20293eae275cee8fd6a6724c0180c4fd9a379408" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:4.25ex; height:2.343ex;" alt="{\displaystyle s_{p-2}}"></span> is 0 in <i>X</i>, it is also 0 modulo <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle M_{p}.}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mi>M</mi> <mrow class="MJX-TeXAtom-ORD"> <mi>p</mi> </mrow> </msub> <mo>.</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle M_{p}.}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/92c6678fb6a6861a85113a54da3292c03da6c426" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.96ex; height:2.843ex;" alt="{\displaystyle M_{p}.}"></span> </p> <div class="mw-heading mw-heading2"><h2 id="Applications">Applications</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=9" title="Edit section: Applications"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>The Lucas–Lehmer test is one of the main primality tests used by the <a href="/wiki/Great_Internet_Mersenne_Prime_Search" title="Great Internet Mersenne Prime Search">Great Internet Mersenne Prime Search</a> (GIMPS) to locate large primes. This search has been successful in locating many of the largest primes known to date.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> The test is considered valuable because it can provably test a large set of very large numbers for primality within an affordable amount of time. In contrast, the equivalently fast <a href="/wiki/P%C3%A9pin%27s_test" title="Pépin's test">Pépin's test</a> for any <a href="/wiki/Fermat_number" title="Fermat number">Fermat number</a> can only be used on a much smaller set of very large numbers before reaching computational limits. </p> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=10" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a href="/wiki/Mersenne%27s_conjecture" class="mw-redirect" title="Mersenne's conjecture">Mersenne's conjecture</a></li> <li><a href="/wiki/Lucas%E2%80%93Lehmer%E2%80%93Riesel_test" title="Lucas–Lehmer–Riesel test">Lucas–Lehmer–Riesel test</a></li></ul> <div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=11" title="Edit section: Notes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text">Formally, let <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathbb {Z} _{q}=\mathbb {Z} /q\mathbb {Z} }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <msub> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>q</mi> </mrow> </msub> <mo>=</mo> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <mi>q</mi> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \mathbb {Z} _{q}=\mathbb {Z} /q\mathbb {Z} }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/b6df752fa6692210acf0053378f51553102eadd7" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:10.97ex; height:3.009ex;" alt="{\displaystyle \mathbb {Z} _{q}=\mathbb {Z} /q\mathbb {Z} }"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle X=\mathbb {Z} _{q}[T]/\langle T^{2}-3\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>X</mi> <mo>=</mo> <msub> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> <mrow class="MJX-TeXAtom-ORD"> <mi>q</mi> </mrow> </msub> <mo stretchy="false">[</mo> <mi>T</mi> <mo stretchy="false">]</mo> <mrow class="MJX-TeXAtom-ORD"> <mo>/</mo> </mrow> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <msup> <mi>T</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>−<!-- − --></mo> <mn>3</mn> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle X=\mathbb {Z} _{q}[T]/\langle T^{2}-3\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/378d7e7ecbd43ed1113fa3fe041c448b2b3c0f75" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:20.296ex; height:3.343ex;" alt="{\displaystyle X=\mathbb {Z} _{q}[T]/\langle T^{2}-3\rangle }"></span>.</span> </li> <li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text">Formally, <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega +\langle T^{2}-3\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> <mo>+</mo> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <msup> <mi>T</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>−<!-- − --></mo> <mn>3</mn> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega +\langle T^{2}-3\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d98cfa3b08afafe30de444dbf68786eda92d4bd5" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.873ex; height:3.176ex;" alt="{\displaystyle \omega +\langle T^{2}-3\rangle }"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\bar {\omega }}+\langle T^{2}-3\rangle }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> <mo>+</mo> <mo fence="false" stretchy="false">⟨<!-- ⟨ --></mo> <msup> <mi>T</mi> <mrow class="MJX-TeXAtom-ORD"> <mn>2</mn> </mrow> </msup> <mo>−<!-- − --></mo> <mn>3</mn> <mo fence="false" stretchy="false">⟩<!-- ⟩ --></mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\bar {\omega }}+\langle T^{2}-3\rangle }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/499dacd0ebf5337a8e404469eb0e709fddfd7109" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.873ex; height:3.176ex;" alt="{\displaystyle {\bar {\omega }}+\langle T^{2}-3\rangle }"></span> are in <i>X</i>. By abuse of language <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \omega }"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mi>ω<!-- ω --></mi> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \omega }</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/48eff443f9de7a985bb94ca3bde20813ea737be8" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.446ex; height:1.676ex;" alt="{\displaystyle \omega }"></span> and <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\bar {\omega }}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mover> <mi>ω<!-- ω --></mi> <mo stretchy="false">¯<!-- ¯ --></mo> </mover> </mrow> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\bar {\omega }}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/4c53181fa3ce2b060f199a67a4bfd2d66277ef6c" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.446ex; height:2.009ex;" alt="{\displaystyle {\bar {\omega }}}"></span> are identified with their images in <i>X</i> under the natural ring homomorphism from <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathbb {Z} [{\sqrt {3}}]}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="double-struck">Z</mi> </mrow> <mo stretchy="false">[</mo> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> <mo stretchy="false">]</mo> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle \mathbb {Z} [{\sqrt {3}}]}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/351aab00a28d03504276ca0af3e3e3e6d038e9bf" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:5.942ex; height:3.009ex;" alt="{\displaystyle \mathbb {Z} [{\sqrt {3}}]}"></span> to <i>X</i> which sends <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\sqrt {3}}}"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <msqrt> <mn>3</mn> </msqrt> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\sqrt {3}}}</annotation> </semantics> </math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/3b19c09494138b5082459afac7f9a8d99c546fcd" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:3.098ex; height:2.843ex;" alt="{\displaystyle {\sqrt {3}}}"></span> to <i>T</i>.</span> </li> </ol></div> <div class="mw-heading mw-heading2"><h2 id="References">References</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=12" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist reflist-columns references-column-width reflist-columns-2"> <ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite id="CITEREFJaroma2004" class="citation journal cs1">Jaroma, John H. (2004). <a rel="nofollow" class="external text" href="https://www.irishmathsoc.org/bull54/M5402.pdf">"Note on the Lucas–Lehmer Test"</a> <span class="cs1-format">(PDF)</span>. <i>Bulletin of the Irish Mathematical Society</i>. <b>54</b> (2). Irish Mathematical Society: 63. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.33232%2FBIMS.0054.63.72">10.33232/BIMS.0054.63.72</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:16831811">16831811</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Bulletin+of+the+Irish+Mathematical+Society&rft.atitle=Note+on+the+Lucas%E2%80%93Lehmer+Test&rft.volume=54&rft.issue=2&rft.pages=63&rft.date=2004&rft_id=info%3Adoi%2F10.33232%2FBIMS.0054.63.72&rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A16831811%23id-name%3DS2CID&rft.aulast=Jaroma&rft.aufirst=John+H.&rft_id=https%3A%2F%2Fwww.irishmathsoc.org%2Fbull54%2FM5402.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-Jansen-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-Jansen_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Jansen_2-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Jansen_2-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-Jansen_2-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-Jansen_2-4"><sup><i><b>e</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFJansen2012" class="citation thesis cs1">Jansen, B.J.H. (2012). <a rel="nofollow" class="external text" href="https://openaccess.leidenuniv.nl/handle/1887/20310"><i>Mersenne primes and class field theory</i></a> (Doctoral thesis). Leiden University. pp. iii–iv<span class="reference-accessdate">. Retrieved <span class="nowrap">2018-12-17</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adissertation&rft.title=Mersenne+primes+and+class+field+theory&rft.inst=Leiden+University&rft.date=2012&rft.aulast=Jansen&rft.aufirst=B.J.H.&rft_id=https%3A%2F%2Fopenaccess.leidenuniv.nl%2Fhandle%2F1887%2F20310&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFRobinson1954" class="citation journal cs1">Robinson, Raphael M. (1954). <a rel="nofollow" class="external text" href="https://doi.org/10.1090%2FS0002-9939-1954-0064787-4">"Mersenne and Fermat numbers"</a>. <i>Proc. Amer. Math. Soc</i>. <b>5</b> (5): 842–846. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1090%2FS0002-9939-1954-0064787-4">10.1090/S0002-9939-1954-0064787-4</a></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Proc.+Amer.+Math.+Soc.&rft.atitle=Mersenne+and+Fermat+numbers&rft.volume=5&rft.issue=5&rft.pages=842-846&rft.date=1954&rft_id=info%3Adoi%2F10.1090%2FS0002-9939-1954-0064787-4&rft.aulast=Robinson&rft.aufirst=Raphael+M.&rft_id=https%3A%2F%2Fdoi.org%2F10.1090%252FS0002-9939-1954-0064787-4&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFHaworth1990" class="citation techreport cs1">Haworth, Guy (1990). <a rel="nofollow" class="external text" href="https://core.ac.uk/download/pdf/12758.pdf?repositoryId=17"><i>Mersenne numbers</i></a> <span class="cs1-format">(PDF)</span> (Technical report). p. 20<span class="reference-accessdate">. Retrieved <span class="nowrap">2018-12-17</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=report&rft.btitle=Mersenne+numbers&rft.pages=20&rft.date=1990&rft.aulast=Haworth&rft.aufirst=Guy&rft_id=https%3A%2F%2Fcore.ac.uk%2Fdownload%2Fpdf%2F12758.pdf%3FrepositoryId%3D17&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFLenstra,_Jr.2001" class="citation conference cs1"><a href="/wiki/Hendrik_Lenstra" title="Hendrik Lenstra">Lenstra, Jr., H. W.</a> (2001-05-13). Buhler, J.; Niederreiter, H.; Pohst, M.E. (eds.). <a rel="nofollow" class="external text" href="http://dagstuhl.sunsite.rwth-aachen.de/volltexte/2021/15190/pdf/DagSemRep-306.pdf"><i>Woltman's conjecture on the Lucas-Lehmer test</i></a> <span class="cs1-format">(PDF)</span>. Algorithms and Number Theory. p. 20<span class="reference-accessdate">. Retrieved <span class="nowrap">2024-10-16</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=conference&rft.btitle=Woltman%27s+conjecture+on+the+Lucas-Lehmer+test&rft.pages=20&rft.date=2001-05-13&rft.aulast=Lenstra%2C+Jr.&rft.aufirst=H.+W.&rft_id=http%3A%2F%2Fdagstuhl.sunsite.rwth-aachen.de%2Fvolltexte%2F2021%2F15190%2Fpdf%2FDagSemRep-306.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFColquittWelsh1991" class="citation cs2">Colquitt, W. N.; Welsh, L. Jr. (1991), "A New Mersenne Prime", <i>Mathematics of Computation</i>, <b>56</b> (194): 867–870, <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2008415">10.2307/2008415</a></span>, <a href="/wiki/JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a> <a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2008415">2008415</a>, <q>The use of the FFT speeds up the asymptotic time for the Lucas–Lehmer test for M<sub><i>p</i></sub> from O(<i>p</i><sup>3</sup>) to O(<i>p</i><sup>2</sup> log <i>p</i> log log <i>p</i>) bit operations.</q></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=Mathematics+of+Computation&rft.atitle=A+New+Mersenne+Prime&rft.volume=56&rft.issue=194&rft.pages=867-870&rft.date=1991&rft_id=info%3Adoi%2F10.2307%2F2008415&rft_id=https%3A%2F%2Fwww.jstor.org%2Fstable%2F2008415%23id-name%3DJSTOR&rft.aulast=Colquitt&rft.aufirst=W.+N.&rft.au=Welsh%2C+L.+Jr.&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFBruce1993" class="citation journal cs1">Bruce, J. W. (1993). "A Really Trivial Proof of the Lucas–Lehmer Test". <i>The American Mathematical Monthly</i>. <b>100</b> (4): 370–371. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.2307%2F2324959">10.2307/2324959</a>. <a href="/wiki/JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a> <a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2324959">2324959</a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=The+American+Mathematical+Monthly&rft.atitle=A+Really+Trivial+Proof+of+the+Lucas%E2%80%93Lehmer+Test&rft.volume=100&rft.issue=4&rft.pages=370-371&rft.date=1993&rft_id=info%3Adoi%2F10.2307%2F2324959&rft_id=https%3A%2F%2Fwww.jstor.org%2Fstable%2F2324959%23id-name%3DJSTOR&rft.aulast=Bruce&rft.aufirst=J.+W.&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">Jason Wojciechowski. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110722232101/http://wonka.hampshire.edu/~jason/math/smithnum/project.ps">Mersenne Primes, An Introduction and Overview</a>. 2003.</span> </li> <li id="cite_note-Rodseth-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-Rodseth_11-0">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFRödseth1994" class="citation journal cs1">Rödseth, Öystein J. (1994). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160306082833/http://folk.uib.no/nmaoy/papers/luc.pdf">"A note on primality tests for N=h·2^n−1"</a> <span class="cs1-format">(PDF)</span>. <i>BIT Numerical Mathematics</i>. <b>34</b> (3): 451–454. <a href="/wiki/Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2FBF01935653">10.1007/BF01935653</a>. <a href="/wiki/S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:120438959">120438959</a>. Archived from <a rel="nofollow" class="external text" href="http://folk.uib.no/nmaoy/papers/luc.pdf">the original</a> <span class="cs1-format">(PDF)</span> on March 6, 2016.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=article&rft.jtitle=BIT+Numerical+Mathematics&rft.atitle=A+note+on+primality+tests+for+N%3Dh%C2%B72%5En%E2%88%921&rft.volume=34&rft.issue=3&rft.pages=451-454&rft.date=1994&rft_id=info%3Adoi%2F10.1007%2FBF01935653&rft_id=https%3A%2F%2Fapi.semanticscholar.org%2FCorpusID%3A120438959%23id-name%3DS2CID&rft.aulast=R%C3%B6dseth&rft.aufirst=%C3%96ystein+J.&rft_id=http%3A%2F%2Ffolk.uib.no%2Fnmaoy%2Fpapers%2Fluc.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span> </li> <li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://primes.utm.edu/largest.html#biggest">The "Top Ten" Record Primes</a>, <a href="/wiki/The_Prime_Pages" class="mw-redirect" title="The Prime Pages">The Prime Pages</a></span> </li> </ol></div> <ul><li><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFCrandallPomerance2001" class="citation cs2"><a href="/wiki/Richard_Crandall" title="Richard Crandall">Crandall, Richard</a>; <a href="/wiki/Carl_Pomerance" title="Carl Pomerance">Pomerance, Carl</a> (2001), "Section 4.2.1: The Lucas–Lehmer test", <i>Prime Numbers: A Computational Perspective</i> (1st ed.), Berlin: Springer, pp. 167–170, <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-387-94777-9" title="Special:BookSources/0-387-94777-9"><bdi>0-387-94777-9</bdi></a></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=Section+4.2.1%3A+The+Lucas%E2%80%93Lehmer+test&rft.btitle=Prime+Numbers%3A+A+Computational+Perspective&rft.place=Berlin&rft.pages=167-170&rft.edition=1st&rft.pub=Springer&rft.date=2001&rft.isbn=0-387-94777-9&rft.aulast=Crandall&rft.aufirst=Richard&rft.au=Pomerance%2C+Carl&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></li></ul> <div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&action=edit&section=13" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><span class="citation mathworld" id="Reference-Mathworld-Lucas–Lehmer_test"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite id="CITEREFWeisstein" class="citation web cs1"><a href="/wiki/Eric_W._Weisstein" title="Eric W. Weisstein">Weisstein, Eric W.</a> <a rel="nofollow" class="external text" href="https://mathworld.wolfram.com/Lucas-LehmerTest.html">"Lucas–Lehmer test"</a>. <i><a href="/wiki/MathWorld" title="MathWorld">MathWorld</a></i>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=MathWorld&rft.atitle=Lucas%E2%80%93Lehmer+test&rft.au=Weisstein%2C+Eric+W.&rft_id=https%3A%2F%2Fmathworld.wolfram.com%2FLucas-LehmerTest.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3ALucas%E2%80%93Lehmer+primality+test" class="Z3988"></span></span></li> <li><a rel="nofollow" class="external text" href="http://www.mersenne.org">GIMPS (The Great Internet Mersenne Prime Search)</a></li> <li><a rel="nofollow" class="external text" href="https://arxiv.org/abs/0705.3664">A proof of Lucas–Lehmer–Reix test (for Fermat numbers)</a></li> <li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20160216234138/http://www.mersennewiki.org/index.php/Lucas-Lehmer_Test">Lucas–Lehmer test</a> at MersenneWiki</li></ul> <div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}</style><style data-mw-deduplicate="TemplateStyles:r1236075235">.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}</style></div><div role="navigation" class="navbox" aria-labelledby="Number-theoretic_algorithms" style="padding:3px"><table class="nowraplinks mw-collapsible uncollapsed navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1129693374"><style data-mw-deduplicate="TemplateStyles:r1239400231">.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}</style><div class="navbar plainlinks hlist navbar-mini"><ul><li class="nv-view"><a href="/wiki/Template:Number-theoretic_algorithms" title="Template:Number-theoretic algorithms"><abbr title="View this template">v</abbr></a></li><li class="nv-talk"><a href="/wiki/Template_talk:Number-theoretic_algorithms" title="Template talk:Number-theoretic algorithms"><abbr title="Discuss this template">t</abbr></a></li><li class="nv-edit"><a href="/wiki/Special:EditPage/Template:Number-theoretic_algorithms" title="Special:EditPage/Template:Number-theoretic algorithms"><abbr title="Edit this template">e</abbr></a></li></ul></div><div id="Number-theoretic_algorithms" style="font-size:114%;margin:0 4em"><a href="/wiki/Number_theory" title="Number theory">Number-theoretic</a> <a href="/wiki/Algorithm" title="Algorithm">algorithms</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Primality_test" title="Primality test">Primality tests</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/AKS_primality_test" title="AKS primality test">AKS</a></li> <li><a href="/wiki/Adleman%E2%80%93Pomerance%E2%80%93Rumely_primality_test" title="Adleman–Pomerance–Rumely primality test">APR</a></li> <li><a href="/wiki/Baillie%E2%80%93PSW_primality_test" title="Baillie–PSW primality test">Baillie–PSW</a></li> <li><a href="/wiki/Elliptic_curve_primality" title="Elliptic curve primality">Elliptic curve</a></li> <li><a href="/wiki/Pocklington_primality_test" title="Pocklington primality test">Pocklington</a></li> <li><a href="/wiki/Fermat_primality_test" title="Fermat primality test">Fermat</a></li> <li><a href="/wiki/Lucas_primality_test" title="Lucas primality test">Lucas</a></li> <li><i><a class="mw-selflink selflink">Lucas–Lehmer</a></i></li> <li><i><a href="/wiki/Lucas%E2%80%93Lehmer%E2%80%93Riesel_test" title="Lucas–Lehmer–Riesel test">Lucas–Lehmer–Riesel</a></i></li> <li><i><a href="/wiki/Proth%27s_theorem" title="Proth's theorem">Proth's theorem</a></i></li> <li><i><a href="/wiki/P%C3%A9pin%27s_test" title="Pépin's test">Pépin's</a></i></li> <li><a href="/wiki/Quadratic_Frobenius_test" title="Quadratic Frobenius test">Quadratic Frobenius</a></li> <li><a href="/wiki/Solovay%E2%80%93Strassen_primality_test" title="Solovay–Strassen primality test">Solovay–Strassen</a></li> <li><a href="/wiki/Miller%E2%80%93Rabin_primality_test" title="Miller–Rabin primality test">Miller–Rabin</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Generating_primes" class="mw-redirect" title="Generating primes">Prime-generating</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Sieve_of_Atkin" title="Sieve of Atkin">Sieve of Atkin</a></li> <li><a href="/wiki/Sieve_of_Eratosthenes" title="Sieve of Eratosthenes">Sieve of Eratosthenes</a></li> <li><a href="/wiki/Sieve_of_Pritchard" title="Sieve of Pritchard">Sieve of Pritchard</a></li> <li><a href="/wiki/Sieve_of_Sundaram" title="Sieve of Sundaram">Sieve of Sundaram</a></li> <li><a href="/wiki/Wheel_factorization" title="Wheel factorization">Wheel factorization</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Integer_factorization" title="Integer factorization">Integer factorization</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Continued_fraction_factorization" title="Continued fraction factorization">Continued fraction (CFRAC)</a></li> <li><a href="/wiki/Dixon%27s_factorization_method" title="Dixon's factorization method">Dixon's</a></li> <li><a href="/wiki/Lenstra_elliptic-curve_factorization" title="Lenstra elliptic-curve factorization">Lenstra elliptic curve (ECM)</a></li> <li><a href="/wiki/Euler%27s_factorization_method" title="Euler's factorization method">Euler's</a></li> <li><a href="/wiki/Pollard%27s_rho_algorithm" title="Pollard's rho algorithm">Pollard's rho</a></li> <li><a href="/wiki/Pollard%27s_p_%E2%88%92_1_algorithm" title="Pollard's p − 1 algorithm"><i>p</i> − 1</a></li> <li><a href="/wiki/Williams%27s_p_%2B_1_algorithm" title="Williams's p + 1 algorithm"><i>p</i> + 1</a></li> <li><a href="/wiki/Quadratic_sieve" title="Quadratic sieve">Quadratic sieve (QS)</a></li> <li><a href="/wiki/General_number_field_sieve" title="General number field sieve">General number field sieve (GNFS)</a></li> <li><i><a href="/wiki/Special_number_field_sieve" title="Special number field sieve">Special number field sieve (SNFS)</a></i></li> <li><a href="/wiki/Rational_sieve" title="Rational sieve">Rational sieve</a></li> <li><a href="/wiki/Fermat%27s_factorization_method" title="Fermat's factorization method">Fermat's</a></li> <li><a href="/wiki/Shanks%27s_square_forms_factorization" title="Shanks's square forms factorization">Shanks's square forms</a></li> <li><a href="/wiki/Trial_division" title="Trial division">Trial division</a></li> <li><a href="/wiki/Shor%27s_algorithm" title="Shor's algorithm">Shor's</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Multiplication_algorithm" title="Multiplication algorithm">Multiplication</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Ancient_Egyptian_multiplication" title="Ancient Egyptian multiplication">Ancient Egyptian</a></li> <li><a href="/wiki/Long_multiplication" class="mw-redirect" title="Long multiplication">Long</a></li> <li><a href="/wiki/Karatsuba_algorithm" title="Karatsuba algorithm">Karatsuba</a></li> <li><a href="/wiki/Toom%E2%80%93Cook_multiplication" title="Toom–Cook multiplication">Toom–Cook</a></li> <li><a href="/wiki/Sch%C3%B6nhage%E2%80%93Strassen_algorithm" title="Schönhage–Strassen algorithm">Schönhage–Strassen</a></li> <li><a href="/wiki/F%C3%BCrer%27s_algorithm" class="mw-redirect" title="Fürer's algorithm">Fürer's</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Euclidean_division" title="Euclidean division">Euclidean</a> <a href="/wiki/Division_algorithm" title="Division algorithm">division</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Binary_division" class="mw-redirect" title="Binary division">Binary</a></li> <li><a href="/wiki/Chunking_(division)" title="Chunking (division)">Chunking</a></li> <li><a href="/wiki/Fourier_division" title="Fourier division">Fourier</a></li> <li><a href="/wiki/Goldschmidt_division" class="mw-redirect" title="Goldschmidt division">Goldschmidt</a></li> <li><a href="/wiki/Newton%E2%80%93Raphson_division" class="mw-redirect" title="Newton–Raphson division">Newton-Raphson</a></li> <li><a href="/wiki/Long_division" title="Long division">Long</a></li> <li><a href="/wiki/Short_division" title="Short division">Short</a></li> <li><a href="/wiki/SRT_division" class="mw-redirect" title="SRT division">SRT</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Discrete_logarithm" title="Discrete logarithm">Discrete logarithm</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Baby-step_giant-step" title="Baby-step giant-step">Baby-step giant-step</a></li> <li><a href="/wiki/Pollard%27s_rho_algorithm_for_logarithms" title="Pollard's rho algorithm for logarithms">Pollard rho</a></li> <li><a href="/wiki/Pollard%27s_kangaroo_algorithm" title="Pollard's kangaroo algorithm">Pollard kangaroo</a></li> <li><a href="/wiki/Pohlig%E2%80%93Hellman_algorithm" title="Pohlig–Hellman algorithm">Pohlig–Hellman</a></li> <li><a href="/wiki/Index_calculus_algorithm" title="Index calculus algorithm">Index calculus</a></li> <li><a href="/wiki/Function_field_sieve" title="Function field sieve">Function field sieve</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Greatest_common_divisor" title="Greatest common divisor">Greatest common divisor</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Binary_GCD_algorithm" title="Binary GCD algorithm">Binary</a></li> <li><a href="/wiki/Euclidean_algorithm" title="Euclidean algorithm">Euclidean</a></li> <li><a href="/wiki/Extended_Euclidean_algorithm" title="Extended Euclidean algorithm">Extended Euclidean</a></li> <li><a href="/wiki/Lehmer%27s_GCD_algorithm" title="Lehmer's GCD algorithm">Lehmer's</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="/wiki/Quadratic_residue" title="Quadratic residue">Modular square root</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Cipolla%27s_algorithm" title="Cipolla's algorithm">Cipolla</a></li> <li><a href="/wiki/Pocklington%27s_algorithm" title="Pocklington's algorithm">Pocklington's</a></li> <li><a href="/wiki/Tonelli%E2%80%93Shanks_algorithm" title="Tonelli–Shanks algorithm">Tonelli–Shanks</a></li> <li><a href="/wiki/Berlekamp%E2%80%93Rabin_algorithm" title="Berlekamp–Rabin algorithm">Berlekamp</a></li> <li><a href="/wiki/Kunerth%27s_algorithm" title="Kunerth's algorithm">Kunerth</a></li></ul> </div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other algorithms</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"> <ul><li><a href="/wiki/Chakravala_method" title="Chakravala method">Chakravala</a></li> <li><a href="/wiki/Cornacchia%27s_algorithm" title="Cornacchia's algorithm">Cornacchia</a></li> <li><a href="/wiki/Exponentiation_by_squaring" title="Exponentiation by squaring">Exponentiation by squaring</a></li> <li><a href="/wiki/Integer_square_root" title="Integer square root">Integer square root</a></li> <li><a href="/wiki/Integer_relation_algorithm" title="Integer relation algorithm">Integer relation</a> (<a href="/wiki/Lenstra%E2%80%93Lenstra%E2%80%93Lov%C3%A1sz_lattice_basis_reduction_algorithm" title="Lenstra–Lenstra–Lovász lattice basis reduction algorithm">LLL</a>; <a href="/wiki/Korkine%E2%80%93Zolotarev_lattice_basis_reduction_algorithm" title="Korkine–Zolotarev lattice basis reduction algorithm">KZ</a>)</li> <li><a href="/wiki/Modular_exponentiation" title="Modular exponentiation">Modular exponentiation</a></li> <li><a href="/wiki/Montgomery_reduction" class="mw-redirect" title="Montgomery reduction">Montgomery reduction</a></li> <li><a href="/wiki/Schoof%27s_algorithm" title="Schoof's algorithm">Schoof</a></li> <li><a href="/wiki/Trachtenberg_system" title="Trachtenberg system">Trachtenberg system</a></li></ul> </div></td></tr><tr><td class="navbox-abovebelow hlist" colspan="2"><div> <ul><li><i>Italics</i> indicate that algorithm is for numbers of special forms</li></ul> </div></td></tr></tbody></table></div> <!-- NewPP limit report Parsed by mw‐web.codfw.main‐f69cdc8f6‐mf4ts Cached time: 20241122141525 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.641 seconds Real time usage: 0.867 seconds Preprocessor visited node count: 1744/1000000 Post‐expand include size: 44765/2097152 bytes Template argument size: 1505/2097152 bytes Highest expansion depth: 13/100 Expensive parser function count: 4/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 49010/5000000 bytes Lua time usage: 0.353/10.000 seconds Lua memory usage: 5839486/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 599.506 1 -total 32.85% 196.960 1 Template:Reflist 20.88% 125.182 4 Template:Cite_journal 20.75% 124.422 1 Template:Number_theoretic_algorithms 20.04% 120.144 1 Template:Navbox 18.44% 110.538 1 Template:Short_description 11.99% 71.892 2 Template:Pagetype 8.41% 50.406 1 Template:Contradict-inline 6.95% 41.670 1 Template:Fix 6.15% 36.880 1 Template:About --> <!-- Saved in parser cache with key enwiki:pcache:idhash:325739-0!canonical and timestamp 20241122141525 and revision id 1251698132. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=Lucas–Lehmer_primality_test&oldid=1251698132">https://en.wikipedia.org/w/index.php?title=Lucas–Lehmer_primality_test&oldid=1251698132</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Categories</a>: <ul><li><a href="/wiki/Category:Primality_tests" title="Category:Primality tests">Primality tests</a></li><li><a href="/wiki/Category:Mersenne_primes" title="Category:Mersenne primes">Mersenne primes</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_is_different_from_Wikidata" title="Category:Short description is different from Wikidata">Short description is different from Wikidata</a></li><li><a href="/wiki/Category:Articles_contradicting_other_articles" title="Category:Articles contradicting other articles">Articles contradicting other articles</a></li><li><a href="/wiki/Category:Wikipedia_articles_needing_clarification_from_September_2022" title="Category:Wikipedia articles needing clarification from September 2022">Wikipedia articles needing clarification from September 2022</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 17 October 2024, at 15:33<span class="anonymous-show"> (UTC)</span>.</li> <li id="footer-info-copyright">Text is available under the <a href="/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" title="Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License">Creative Commons Attribution-ShareAlike 4.0 License</a>; additional terms may apply. By using this site, you agree to the <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use" class="extiw" title="foundation:Special:MyLanguage/Policy:Terms of Use">Terms of Use</a> and <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy" class="extiw" title="foundation:Special:MyLanguage/Policy:Privacy policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a rel="nofollow" class="external text" href="https://wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=Lucas%E2%80%93Lehmer_primality_test&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-f69cdc8f6-h2npf","wgBackendResponseTime":119,"wgPageParseReport":{"limitreport":{"cputime":"0.641","walltime":"0.867","ppvisitednodes":{"value":1744,"limit":1000000},"postexpandincludesize":{"value":44765,"limit":2097152},"templateargumentsize":{"value":1505,"limit":2097152},"expansiondepth":{"value":13,"limit":100},"expensivefunctioncount":{"value":4,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":49010,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 599.506 1 -total"," 32.85% 196.960 1 Template:Reflist"," 20.88% 125.182 4 Template:Cite_journal"," 20.75% 124.422 1 Template:Number_theoretic_algorithms"," 20.04% 120.144 1 Template:Navbox"," 18.44% 110.538 1 Template:Short_description"," 11.99% 71.892 2 Template:Pagetype"," 8.41% 50.406 1 Template:Contradict-inline"," 6.95% 41.670 1 Template:Fix"," 6.15% 36.880 1 Template:About"]},"scribunto":{"limitreport-timeusage":{"value":"0.353","limit":"10.000"},"limitreport-memusage":{"value":5839486,"limit":52428800}},"cachereport":{"origin":"mw-web.codfw.main-f69cdc8f6-mf4ts","timestamp":"20241122141525","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"Lucas\u2013Lehmer primality test","url":"https:\/\/en.wikipedia.org\/wiki\/Lucas%E2%80%93Lehmer_primality_test","sameAs":"http:\/\/www.wikidata.org\/entity\/Q1138992","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q1138992","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2003-09-23T21:24:28Z","dateModified":"2024-10-17T15:33:18Z","headline":"primality test"}</script> </body> </html>