{"id":27,"date":"2026-11-24T18:26:20","date_gmt":"2026-11-24T12:56:20","guid":{"rendered":"https:\/\/casinozox.com\/blog\/?p=27"},"modified":"2026-11-24T18:26:20","modified_gmt":"2026-11-24T12:56:20","slug":"shors-algorithm-explained-how-a-quantum-computer-factors-numbers","status":"publish","type":"post","link":"https:\/\/casinozox.com\/blog\/shors-algorithm-explained-how-a-quantum-computer-factors-numbers\/","title":{"rendered":"Shor&#8217;s Algorithm Explained: How a Quantum Computer Factors Numbers"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"572\" src=\"https:\/\/casinozox.com\/blog\/wp-content\/uploads\/2026\/11\/image-4.png\" alt=\"\" class=\"wp-image-28\" srcset=\"https:\/\/casinozox.com\/blog\/wp-content\/uploads\/2026\/11\/image-4.png 1024w, https:\/\/casinozox.com\/blog\/wp-content\/uploads\/2026\/11\/image-4-768x429.png 768w, https:\/\/casinozox.com\/blog\/wp-content\/uploads\/2026\/11\/image-4-300x168.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Few quantum algorithms get as much attention as the one invented by mathematician Peter Shor in 1994. It is often described in dramatic terms, such as &#8220;the algorithm that will break the internet.&#8221; The truth is more careful and more interesting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide gives you <strong>Shor&#8217;s algorithm explained<\/strong> from the ground up. You will see what problem it solves, how it works in four clear stages, and a complete worked example you can follow with a pencil. No programming is needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Problem: Why Factoring Is Hard<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every whole number can be broken into prime numbers. For example, 15 = 3 \u00d7 5, and the numbers 3 and 5 are its prime factors. Finding them is called <strong>factoring<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For small numbers, this is easy. For numbers with hundreds of digits, no known classical method can do it in a reasonable time. Multiplying two big primes takes a moment, but undoing that product is extraordinarily slow. This one-way difficulty is what protects many public-key security systems today, including the widely used RSA method.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shor&#8217;s algorithm matters because it shows that a quantum computer could, in principle, factor large numbers far faster than any known classical method. That is a statement about a mathematical possibility, and a machine large enough to do it does not exist yet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Big Idea in One Sentence<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Shor&#8217;s key insight is that factoring can be turned into a different problem: <strong>finding a repeating pattern<\/strong>. <strong><a href=\"https:\/\/www.quantumuting.com\/\" data-type=\"link\" data-id=\"https:\/\/www.quantumuting.com\/\">Quantum <\/a><\/strong>computers are very good at spotting such patterns, and classical computers are not.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So the algorithm is a partnership. A classical computer prepares and finishes the job, and a quantum computer handles the one step it does best.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Four Stages<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Stage 1: Pick a guess (classical)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose we want to factor a number N. We choose a random number a smaller than N. If a happens to share a factor with N, we are already done, and that is a lucky shortcut. Otherwise, we move on.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Stage 2: Find the repeating pattern (quantum)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now consider the numbers you get by raising a to higher and higher powers and taking the remainder after dividing by N. This list always starts repeating. The number of steps before it returns to 1 is called the <strong>period<\/strong>, often written r.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finding r is easy for tiny numbers and extremely hard for huge ones on a classical computer. This is the step handed to the quantum computer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Stage 3: Use the pattern (classical)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If r is even, and a certain extra condition holds, then simple arithmetic with a raised to the power r\/2 produces numbers that share factors with N. A routine called the greatest common divisor, which is a fast classical method, extracts those factors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Stage 4: Check and repeat (classical)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The process can fail for unlucky choices of a. If so, we simply pick a new a and repeat. This is acceptable because the algorithm is <strong>probabilistic<\/strong>, meaning each attempt has a good chance of success, not a guarantee.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Worked Example: Factoring 15<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s walk through the whole method with N = 15. We already know the answer is 3 \u00d7 5, which makes it perfect for checking the steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Stage 1:<\/strong> Choose a = 7. The numbers 7 and 15 share no common factor, so we continue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Stage 2:<\/strong> List the powers of 7, keeping only the remainder after dividing by 15.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Power<\/th><th>Value of 7 to that power<\/th><th>Remainder after dividing by 15<\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>7<\/td><td>7<\/td><\/tr><tr><td>2<\/td><td>49<\/td><td>4<\/td><\/tr><tr><td>3<\/td><td>343<\/td><td>13<\/td><\/tr><tr><td>4<\/td><td>2,401<\/td><td>1<\/td><\/tr><tr><td>5<\/td><td>16,807<\/td><td>7<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After four steps the remainder is 1, and then the pattern repeats from 7. So the period is <strong>r = 4<\/strong>. In real use, the quantum computer would find this r.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Stage 3:<\/strong> Since r = 4 is even, we compute 7 to the power r\/2, which is 7\u00b2 = 49. Then we look at the two neighbors, 48 and 50.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The greatest common divisor of 48 and 15 is <strong>3<\/strong>.<\/li>\n\n\n\n<li>The greatest common divisor of 50 and 15 is <strong>5<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">We found the factors: 15 = 3 \u00d7 5.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a number like 15, you could have guessed the answer instantly. The point is that the same four stages work for enormous numbers, where guessing is hopeless and only Stage 2 is difficult.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What the Quantum Part Actually Does<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the heart of <strong>quantum computing algorithms explained<\/strong> for this case. Stage 2 uses ideas from the basics of quantum computing.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Qubits.<\/strong> A qubit is a quantum bit. If you are wondering <strong>what is a qubit<\/strong>, think of it as a unit of information described by amplitudes that set the odds of reading 0 or 1. Shor&#8217;s algorithm uses two groups of qubits, one to hold numbers to test and one to hold the results.<\/li>\n\n\n\n<li><strong>Gates.<\/strong> <strong>Quantum gates explained<\/strong> briefly: gates are operations that change qubit states in a controlled way. The algorithm first uses gates to create an equal mix of many input values at once. It then applies the modular arithmetic as a quantum circuit.<\/li>\n\n\n\n<li><strong>Interference.<\/strong> The amplitudes of different possibilities add or cancel, much like overlapping waves. A tool called the <strong>quantum Fourier transform<\/strong> arranges this interference so that amplitudes pile up on values that reveal the period.<\/li>\n\n\n\n<li><strong>Measurement.<\/strong> Finally, the qubits are measured. The result is a number that relates to the period. A bit of classical maths turns it into r.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A common mistake is to think the quantum computer &#8220;tries all possibilities and picks the right one.&#8221; It does not. It sets up a calculation where wrong answers cancel and the useful pattern becomes likely when measured. Because measurement is probabilistic, the quantum step is often run several times.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why the Speedup Is So Large<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The best known classical methods for factoring slow down very quickly as numbers grow. Shor&#8217;s algorithm, by contrast, takes a number of steps that grows only polynomially with the number of digits. This is a very large advantage for this specific problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But it is important to keep a fair view of <strong>quantum computing vs classical computing<\/strong>. This advantage applies to factoring and related problems, such as the discrete logarithm. It does not mean a quantum computer is faster at everything. For most everyday tasks, it offers no benefit at all.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is Needed in Practice<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here is where the dramatic headlines run ahead of reality.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Many reliable qubits.<\/strong> Real qubits are noisy and lose their state quickly. To run Shor&#8217;s algorithm on numbers used in real security, researchers expect a machine to need error correction, with a large number of physical qubits protecting each reliable &#8220;logical&#8221; qubit.<\/li>\n\n\n\n<li><strong>Very long, accurate circuits.<\/strong> The arithmetic requires millions or more operations. Today&#8217;s devices cannot hold their state for that long without error correction.<\/li>\n\n\n\n<li><strong>Error correction at scale.<\/strong> This has been demonstrated in small experiments, but it is not yet available at the scale needed.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So far, published demonstrations of the algorithm have factored only tiny numbers such as 15 or 21, and some of these experiments used simplifications that relied on knowing the answer in advance. No real-world encryption has been broken with Shor&#8217;s algorithm.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Estimates for the machine size needed have changed over time as researchers find more efficient methods, and they differ from study to study. Because of that uncertainty, no one can give a reliable date.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why It Still Matters Today<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If a large machine is years away, why does the algorithm get so much attention?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because security upgrades take a long time. Some information must stay confidential for decades, and an adversary could record encrypted data now and try to unlock it later. For that reason, standards bodies have been preparing replacements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Post-quantum cryptography explained<\/strong> in short: it is a family of new methods that run on ordinary computers and are designed to resist attacks from both classical and quantum computers. In August 2024, NIST published its first finalized standards in this area. Importantly, Shor&#8217;s algorithm affects public-key schemes like RSA and elliptic curves, while symmetric encryption and hash functions are affected much less and can be strengthened by using longer keys.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Misunderstandings<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&#8220;Shor&#8217;s algorithm has already broken encryption.&#8221;<\/strong> It has not. Only tiny numbers have been factored in experiments.<\/li>\n\n\n\n<li><strong>&#8220;It tries every factor at once.&#8221;<\/strong> It does not. It finds a repeating pattern through interference.<\/li>\n\n\n\n<li><strong>&#8220;Quantum computers can crack any code.&#8221;<\/strong> No. Many cryptographic tools are not affected in the same way.<\/li>\n\n\n\n<li><strong>&#8220;The quantum computer does all the work.&#8221;<\/strong> In fact, most of the steps are classical. Only the period-finding step is quantum.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Who invented Shor&#8217;s algorithm?<\/strong><br>Mathematician Peter Shor described it in 1994 while working at Bell Labs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Is the algorithm guaranteed to work every time?<\/strong><br>No. It is probabilistic, so a run may fail and need repeating with a different starting number.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Does it work on any number?<\/strong><br>It works on numbers that are not prime and not simple powers of a prime. Those special cases are easy to check classically first.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why can&#8217;t classical computers find the period quickly?<\/strong><br>For huge numbers, the repeating cycle can be astronomically long, and no known classical method finds it efficiently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Does Shor&#8217;s algorithm threaten all of cybersecurity?<\/strong><br>No. It threatens a specific group of public-key methods. Other tools, such as symmetric ciphers with longer keys, are much less affected.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Is there a quantum algorithm that breaks hash functions?<\/strong><br>Grover&#8217;s algorithm speeds up searching but only by a square-root factor, which is a far smaller effect than Shor&#8217;s.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How can a beginner study this properly?<\/strong><br>Start with modular arithmetic and basic quantum gates, then work through small examples like the one above before looking at the quantum Fourier transform.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Shor&#8217;s algorithm is best understood as a clever translation. It turns the hard task of factoring into the task of finding a repeating pattern, and then uses quantum interference to find that pattern efficiently. The rest is ordinary arithmetic you can do by hand, as the example with 15 shows.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Its importance is real, but so are the limits. The machines it needs do not exist yet, and nothing in use today has been broken by it. The right response is calm preparation: understand the idea, follow reliable standards, and treat dramatic claims with care.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Few quantum algorithms get as much attention as the one invented by mathematician Peter Shor in 1994. It is often described in dramatic terms, such as &#8220;the algorithm\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[52,47,55,54,53],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-general","tag-quantumcircuits","tag-quantumcomputing","tag-quantumcryptography","tag-quantumtech","tag-qubits"],"_links":{"self":[{"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":1,"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":29,"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions\/29"}],"wp:attachment":[{"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/casinozox.com\/blog\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}