shor

Factor composite integers via quantum period finding and classical post-processing.

30|2|Updated Apr 16, 2026
One-click install
npx skills add https://github.com/unitarylab/quantum-skills --skill shor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shor
Source: https://github.com/unitarylab/quantum-skills/tree/main/algorithms/cryptography/shor
Command: npx skills add https://github.com/unitarylab/quantum-skills --skill shor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires unitarylab, and includes scripts (resource) components.

What problem does it solve?

Shor's algorithm factors a given composite integer efficiently by reducing factoring to quantum period finding and classical post-processing.

Core Features & Use Cases

  • Quantum period finding using QPE and IQFT to derive the order r.
  • Two circuit implementations: matrix-based modular exponentiation and operator-based modular addition.
  • Classical post-processing with continued fractions to extract factors and a retry mechanism for challenging cases.
  • Educational and demonstrative use: factor small integers like 15 or 21 to illustrate the workflow.

Quick Start

Use a small factoring example with N=15 using the matrix method to observe factors.

Frequently Asked Questions about shor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does quantum period finding work for integer factorization?

Quantum period finding uses Quantum Phase Estimation and Inverse Quantum Fourier Transform to derive the order r, reducing factoring to classical post-processing with continued fractions and gcd to extract factors.

How do I factor small integers using Shor's algorithm in Python?

You can factor small integers like N=15 by running a Python pipeline with modular exponentiation circuits, followed by continued fractions and a retry loop to handle challenging cases and extract factors.

What is the difference between matrix-based and operator-based circuits for modular exponentiation?

Matrix-based modular exponentiation and operator-based modular addition are two circuit implementation methods provided for quantum period finding, offering distinct approaches to building the modular exponentiation step.

Can I use this for simulating quantum factorization on larger numbers?

This implementation is applicable to educational demonstrations and research prototyping of modular exponentiation and QPE-based period finding, targeting simulations on small integers rather than large-scale factoring.

Why does quantum factorization fail to find factors on some attempts?

Quantum factorization may fail on certain attempts due to challenging period results, which is why the pipeline includes a classical retry loop to re-attempt factor extraction using continued fractions and gcd.