{"id":66822,"date":"2026-10-15T09:20:32","date_gmt":"2026-10-15T06:20:32","guid":{"rendered":"https:\/\/wpcalc.com\/en\/?p=66822"},"modified":"2026-10-15T09:20:32","modified_gmt":"2026-10-15T06:20:32","slug":"prime-number-checker","status":"publish","type":"post","link":"https:\/\/wpcalc.com\/en\/mathematics\/prime-number-checker\/","title":{"rendered":"Prime Number Checker"},"content":{"rendered":"<section class=\"not-prose calculator-box\" aria-labelledby=\"calculator-title\"><div class=\"flex items-baseline sm:items-center justify-between gap-2 sm:gap-3\"><div class=\"flex flex-col sm:flex-row sm:items-center gap-2\"><span class=\"icon icon-calculator text-primary-700! text-base! dark:text-primary-300!\" aria-hidden=\"true\"><\/span><h2 id=\"calculator-title\" class=\"text-lg font-display font-bold\">Is This Number Prime?<\/h2><\/div><div class=\"calcdash-favorite group\">\n  <button type=\"button\" class=\"favorite\" id=\"favorite\" data-favorite-id=\"66822\" data-favorite-title=\"Prime Number Checker\" data-favorite-url=\"https:\/\/wpcalc.com\/en\/mathematics\/prime-number-checker\/\" data-favorite-excerpt=\"Enter any whole number up to one trillion and instantly find out whether it is prime or composite. The calculator also shows the smallest prime factor and the complete prime factorization with an explanation.\" aria-label=\"Add to Favorites\" data-favorite-icon=\"icon icon-arithmetic\">\n    <span class=\"icon icon-shape-star-empty\" aria-hidden=\"true\"><\/span>\n  <\/button>\n  <div class=\"calcdash-favorite__tip\" aria-hidden=\"true\">\n   <span class=\"favorite-tooltip\" id=\"favorite-tooltip\"><\/span>\n  <\/div>\n  <span class=\"sr-only\" role=\"status\" id=\"favorite-status\"><\/span>\n<\/div><\/div><form action=\"https:\/\/wpcalc.com\/en\/mathematics\/prime-number-checker\/\" method=\"POST\" class=\"calculator\" id=\"calculator-66822\" data-post=\"66822\"><fieldset class=\"fieldset-input is-1\"><legend class=\"sr-only\">Input Fields<\/legend><div class=\"field has-term\" id=\"input-1\"><label for=\"field-1\">Number to check (n)<\/label><div class=\"term\">n<\/div>  <div class=\"absolute bottom-0 left-16 top-8 w-2 h-0.5 bg-blue-500\"><\/div><input type=\"text\" name=\"number_to_check_n\" id=\"field-1\" aria-describedby=\"calc-info-1\" data-number inputmode=\"decimal\" autocomplete=\"off\" spellcheck=\"false\" placeholder=\"e.g. 91\" min=\"0\" max=\"1000000000000\" value=\"91\"\/><small id=\"calc-info-1\">Any whole number from 0 to 1,000,000,000,000<\/small><\/div><\/fieldset><div class=\"buttons\"><button type=\"submit\" data-text=\"Re-Calculate\" id=\"calculate-button\" data-post=\"66822\">Calculate<\/button><button type=\"reset\">Reset<\/button><\/div><div class=\"field is-checkbox hidden!\" id=\"field-auto-calc\"><input type=\"checkbox\" id=\"auto-calc\"><label for=\"auto-calc\">Calculate automatically<\/label><small>If enabled, the result will update automatically when you change any value.<\/small><\/div><div class=\"fieldset-result is-hidden\" aria-labelledby=\"result-title\" aria-live=\"polite\" role=\"region\"> <h3 class=\"result-title bg-gradient-to-r from-primary-50 to-gray-50 dark:from-primary-900 dark:to-gray-800\" id=\"result-title\"><span class=\"icon icon-s-pulse\" aria-hidden=\"true\"><\/span> Your Results<\/h3><div class=\"result-box\"><div class=\"field-result\" id=\"output-1\"><span class=\"field-title\"><span>Result \u2014 prime or composite<\/span><span class=\"result-term\">verdict<\/span><\/span><span class=\"field-value\" id=\"result-1\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><div class=\"field-result\" id=\"output-2\"><span class=\"field-title\"><span>A prime factor (shown if composite)<\/span><span class=\"result-term\">p<\/span><\/span><span class=\"field-value\" id=\"result-2\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><div class=\"field-result is-column\" id=\"output-3\"><span class=\"field-title\"><span>Full prime factorization and explanation<\/span><\/span><span class=\"field-value\" id=\"result-3\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><\/div><div class=\"result-actions\"><button type=\"button\" class=\"copy-link\"><svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z\"\/><path d=\"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z\"\/><\/svg><span class=\"copy-link__text\">Copy link to this calculation<\/span><\/button><span class=\"sr-only\" role=\"status\" id=\"copy-link-status\"><\/span><\/div><\/div><a href=\"#respond\" class=\"hidden transition-opacity duration-300 opacity-0 w-50 text-sm justify-center items-center gap-2 px-4 py-2 rounded bg-gray-200 text-gray-700 hover:bg-gray-300\" id=\"leave-comment\"><span class=\"icon icon-comments\" aria-hidden=\"true\"><\/span>Leave a Comment<\/a><\/form><\/section><section id=\"calc-reactions\" class=\"not-prose hidden my-12 bg-gradient-to-r from-primary-50 to-gray-50 border border-indigo-100 rounded-xl px-6 py-4 shadow-sm\" data-post=\"66822\" aria-live=\"polite\" aria-labelledby=\"calc-reactions-title\"><p id=\"calc-reactions-title\" class=\"text-sm text-gray-500 text-center mb-2\">How did this result make you feel?<\/p><div role=\"group\" aria-labelledby=\"calc-reactions-title\" class=\"grid grid-cols-3 sm:flex sm:flex-row sm:justify-around gap-4 sm:items-center sm:flex-wrap\"><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"like\"><span class=\"reaction-count\" data-reaction-count=\"like\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\ude00 <\/span><span class=\"reaction-description font-medium\">Like <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"helpful\"><span class=\"reaction-count\" data-reaction-count=\"helpful\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\udca1 <\/span><span class=\"reaction-description font-medium\">Helpful <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"confused\"><span class=\"reaction-count\" data-reaction-count=\"confused\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\ude15 <\/span><span class=\"reaction-description font-medium\">Confused <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"disappointed\"><span class=\"reaction-count\" data-reaction-count=\"disappointed\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\ude1e <\/span><span class=\"reaction-description font-medium\">Disappointed <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"inaccurate\"><span class=\"reaction-count\" data-reaction-count=\"inaccurate\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\u274c <\/span><span class=\"reaction-description font-medium\">Inaccurate <\/span><\/button><\/div><div id=\"reaction-message\" class=\"hidden mt-8 rounded-md border border-primary-100 bg-white\/50 backdrop-blur-sm px-4 py-2 text-sm text-center shadow-sm\"><\/div><\/section><div class=\"calcdash-ad not-prose calcdash-ad--calc_result calcdash-ad--in-article\"><ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-1721569815777345\" data-ad-slot=\"6317458308\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\"><\/ins><script>(adsbygoogle = window.adsbygoogle || []).push({});<\/script><\/div>\n<style id=\"wpcoderpro-inline-1\">.formula-box {\r\n\tborder-bottom: none !important;\r\n}<\/style><section class=\"formula-box\" aria-labelledby=\"formula-title\">\r\n\t<div id=\"formula-title\" class=\"not-prose font-display mb-4\"><span class=\"icon icon-formula\" aria-hidden=\"true\"><\/span><h2>Prime Number Checker Formula<\/h2><\/div>\r\n\t<figure class=\"not-prose formula\">\r\n\t\t<figcaption class=\"formula-title\">Formula<\/figcaption>\r\n\t\t<div class=\"text-base text-gray-800\" id=\"formula\">\n\\[ n \\text{ is prime} \\;\\iff\\; n &gt; 1 \\text{ and no integer } d \\text{ with } 1 &lt; d \\le \\sqrt{n} \\text{ divides } n \\]\n<\/div>\r\n\t<\/figure>\r\n\t<\/p>\n<p><strong>Where:<\/strong><\/p>\n<ul>\n<li>\\(n\\) \u2014 the whole number being tested<\/li>\n<li>\\(d\\) \u2014 a candidate divisor<\/li>\n<li>\\(\\sqrt{n}\\) \u2014 the square root of \\(n\\), rounded down to the nearest integer<\/li>\n<\/ul>\n<p>The formula expresses the trial division test: it is enough to search for divisors up to \\(\\sqrt{n}\\), because if \\(n = a \\times b\\) with both factors greater than 1, at least one of them cannot exceed \\(\\sqrt{n}\\). This is why the calculator only tests candidates up to the square root, skipping multiples of 2 and 3 (it checks 2, 3, and then numbers of the form \\(6k \\pm 1\\)).<\/p>\n<p>\r\n<\/section>\n<style id=\"wpcoderpro-inline-459\">.calculation-box {\r\n\tborder-bottom: none !important;\r\n}<\/style><section id=\"calculation\" class=\"calculation-box\" aria-labelledby=\"calculation-title\">\r\n\t<div id=\"calculation-title\" class=\"not-prose font-display\"><span class=\"icon icon-unordered-list\" aria-hidden=\"true\"><\/span><h2>Prime Number Checker \u2013 Calculation Example<\/h2><\/div>\r\n\r\n<\/p>\n<p><strong>Example:<\/strong> is 91 a prime number? We test candidate divisors up to \\(\\sqrt{91} \\approx 9.54\\), so only 2, 3, 5 and 7 need to be checked.<\/p>\n<p>\\[ 91 \\div 2 = 45.5 \\quad (\\text{not a divisor}) \\]<\/p>\n<p>\\[ 91 \\div 3 = 30.\\overline{3} \\quad (\\text{not a divisor}) \\]<\/p>\n<p>\\[ 91 \\div 5 = 18.2 \\quad (\\text{not a divisor}) \\]<\/p>\n<p>\\[ 91 \\div 7 = 13 \\quad (\\text{exact \u2014 7 is a divisor!}) \\]<\/p>\n<p><strong>Result:<\/strong> 91 is a <strong>composite<\/strong> number. Its smallest prime factor is 7, since \\(91 = 7 \\times 13\\), and the full prime factorization is \\(91 = 7 \\times 13\\).<\/p>\n<p>\n\r\n<\/section>\n<h2>How to Use the Prime Number Checker<\/h2>\n<ol>\n<li>Enter the whole number you want to test in the <strong>Number to check (n)<\/strong> field. Any integer from 0 to 1,000,000,000,000 (10<sup>12<\/sup>) is accepted.<\/li>\n<li>Read the <strong>Result \u2014 prime or composite<\/strong> line for the verdict. Numbers below 2 are reported as neither prime nor composite.<\/li>\n<li>If the number is composite, check <strong>A prime factor (shown if composite)<\/strong> \u2014 this is the smallest prime that divides your number, together with its cofactor.<\/li>\n<li>Read the <strong>Full prime factorization and explanation<\/strong> section, which breaks the number into prime factors and explains how the answer was verified.<\/li>\n<\/ol>\n<h2>What Is a Prime Number?<\/h2>\n<p>A <strong>prime number<\/strong> is a whole number greater than 1 that has exactly two positive divisors: 1 and itself. The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. Every other whole number greater than 1 is <strong>composite<\/strong>, meaning it can be written as a product of two smaller whole numbers, both greater than 1.<\/p>\n<p>The number 2 deserves a special mention: it is the only even prime, since every other even number is divisible by 2. The numbers 0 and 1 are neither prime nor composite \u2014 1 has only one divisor, and 0 is divisible by every positive integer, so neither fits the definition of \"exactly two divisors.\"<\/p>\n<p>Prime numbers are the building blocks of arithmetic. The <strong>fundamental theorem of arithmetic<\/strong> states that every whole number greater than 1 factors into primes in exactly one way (apart from the order of the factors). That is why the calculator shows the complete prime factorization whenever the number is composite: it tells you exactly which prime building blocks make up your number, and how many times each appears.<\/p>\n<p>Interpreting the result is straightforward. If the verdict is <em>prime<\/em>, the number cannot be broken down further. If it is <em>composite<\/em>, the smallest prime factor shown is the easiest way to prove it \u2014 dividing your number by that factor yields a whole number, which immediately rules out primality.<\/p>\n<h2>Assumptions, Limitations and Tips<\/h2>\n<ul>\n<li><strong>Range:<\/strong> the calculator accepts integers from 0 to 10<sup>12<\/sup>. Larger numbers require more advanced methods.<\/li>\n<li><strong>Method:<\/strong> it uses trial division with the \\(6k \\pm 1\\) optimization, which is fast and gives a mathematically certain answer for numbers in the supported range. Probabilistic tests such as <a href=\"https:\/\/wpcalc.com\/en\/mathematics\/fermats-little-theorem\/\">Fermat's Little Theorem<\/a> are used instead for astronomically large numbers, because trial division becomes too slow even though it is exact.<\/li>\n<li><strong>Decimals and negatives:<\/strong> primality is defined only for whole numbers greater than 1, so decimal entries, negative numbers, and 0 or 1 return an explanation rather than a verdict.<\/li>\n<li><strong>Quick manual checks:<\/strong> before using the calculator, you can often rule out primality mentally \u2014 a number ending in 0, 2, 4, 5, 6 or 8 is divisible by 2 or 5, and a number whose digits sum to a multiple of 3 (as with 91, since 9 + 1 = 10... check: 10 is not divisible by 3, so that shortcut fails here) is divisible by 3. The digit-sum test relates to the <a href=\"https:\/\/wpcalc.com\/en\/mathematics\/digital-root-calculator\/\">digital root<\/a>.<\/li>\n<li><strong>Why factorization matters:<\/strong> prime factorizations are the foundation of many number-theory tools, from the <a href=\"https:\/\/wpcalc.com\/en\/mathematics\/multiplicative-inverse-modulo\/\">multiplicative inverse modulo n<\/a> used in cryptography to solving congruence systems with the <a href=\"https:\/\/wpcalc.com\/en\/mathematics\/chinese-remainder-theorem\/\">Chinese Remainder Theorem<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Enter any whole number up to one trillion and instantly find out whether it is prime or composite. The calculator also shows the smallest prime factor and the complete prime factorization with an explanation.<\/p>\n","protected":false},"author":3168,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7],"tags":[72],"class_list":["post-66822","post","type-post","status-publish","format-standard","hentry","category-mathematics","tag-arithmetic-calculators"],"acf":[],"_links":{"self":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts\/66822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/users\/3168"}],"replies":[{"embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/comments?post=66822"}],"version-history":[{"count":1,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts\/66822\/revisions"}],"predecessor-version":[{"id":67053,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts\/66822\/revisions\/67053"}],"wp:attachment":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/media?parent=66822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/categories?post=66822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/tags?post=66822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}