Luhn Algorithm
Modulus-10 check-digit formula for detecting entry errors in decimal identification numbers
The Luhn algorithm, patented by IBM scientist Hans Peter Luhn (US2950048A, filed July 20, 1954; granted August 23, 1960), is a modulus-10 check-digit formula used to catch accidental typing errors in numeric identifiers. It doubles alternate digits from the right, sums the resulting individual digits, and checks whether the total is divisible by 10. It is used in payment card PANs, mobile IMEIs, and U.S. National Provider Identifiers (NPIs), verifying format validity only.
- Inventor
- Hans Peter Luhn (IBM)1
- U.S. Patent
- US2950048A (filed 1954-07-20, granted 1960-08-23)1
- Method
- Modulus-10 double-add-double check digit5
- Major Applications
- Payment card PAN, mobile IMEI, U.S. NPI2
- NPI Prefix Rule
- Calculated with 80840 prefix (adds constant 24)5
- Validation Limit
- Format check only; does not prove issuance2
The Luhn algorithm (modulus-10 double-add-double formula) is a simple checksum method invented by Hans Peter Luhn to detect accidental transcription errors in decimal identification numbers using a trailing check digit.
Also known as Luhn formula, Modulus 10 algorithm, Mod 10 check
Origin and Patent History
The Luhn algorithm was invented by Hans Peter Luhn, whose U.S. patent US2950048A ('Computer for Verifying Numbers') was filed on July 20, 1954 and granted on August 23, 1960.1 Designed as a fast, low-cost error-detection scheme for numeric records, the formula entered the public domain and became a standard check-digit mechanism across finance, telecommunications, and healthcare.145
- 1US2950048A: Computer for Verifying Numbers (Hans Peter Luhn)Google Patents (USPTO) ↗
- 4ETSI TS 123 003 V18.7.0 (Annex B: IMEI Check Digit)European Telecommunications Standards Institute (ETSI) ↗
- 5NPI Check Digit Technical SpecificationCenters for Medicare & Medicaid Services (CMS) ↗
Modulus-10 Calculation Steps
To validate an existing numeric string that includes its trailing check digit, the algorithm doubles every second digit moving from right to left (starting with the second-to-last digit). Whenever doubling produces a two-digit number (10 to 18), its individual digits are summed (equivalently subtracting 9).156
- 1US2950048A: Computer for Verifying Numbers (Hans Peter Luhn)Google Patents (USPTO) ↗
- 5NPI Check Digit Technical SpecificationCenters for Medicare & Medicaid Services (CMS) ↗
- 6LuhnCheckDigit API Documentation (Apache Commons Validator 1.11.0)Apache Software Foundation ↗
All resulting values are added to the unchanged digits. If the grand total modulo 10 equals 0, the number passes the Luhn check.56 When generating a new check digit for a payload without one, doubling starts at the rightmost payload digit and the check digit is the amount needed to reach the next multiple of 10.5
- 5NPI Check Digit Technical SpecificationCenters for Medicare & Medicaid Services (CMS) ↗
- 6LuhnCheckDigit API Documentation (Apache Commons Validator 1.11.0)Apache Software Foundation ↗
Applications: Payment Cards, IMEI, and U.S. NPI
The Luhn check digit is widely deployed across standardized identifier systems:
¶- Payment Card Primary Account Numbers (PANs): Payment networks and merchants use the Luhn check to catch mistyped card numbers before authorization.2
- Mobile Device IMEIs: Both GSMA's IMEI Database User Guide and ETSI TS 123 003 Annex B specify the Luhn formula for computing the 15th check digit of an International Mobile Equipment Identity (IMEI).34
- U.S. National Provider Identifiers (NPIs): The Centers for Medicare & Medicaid Services (CMS) applies the Luhn formula to 10-digit NPIs as if prefixed by
80840(health application + U.S. country code), implemented by adding the constant 24 when validating a bare 10-digit NPI.5
- 2PCI SSC FAQ 1137: Account Number Validation and Issuance StatusPCI Security Standards Council ↗
- 3IMEI Database Device Manufacturers User Guide (Version 4.0)GSMA ↗
- 4ETSI TS 123 003 V18.7.0 (Annex B: IMEI Check Digit)European Telecommunications Standards Institute (ETSI) ↗
- 5NPI Check Digit Technical SpecificationCenters for Medicare & Medicaid Services (CMS) ↗
Error-Detection Limits and Format vs. Issuance
The Luhn algorithm catches any single-digit transcription error and most adjacent-digit transpositions (except 09 swapped with 90), but it is not a cryptographic hash and provides no protection against deliberate forgery.16
- 1US2950048A: Computer for Verifying Numbers (Hans Peter Luhn)Google Patents (USPTO) ↗
- 6LuhnCheckDigit API Documentation (Apache Commons Validator 1.11.0)Apache Software Foundation ↗
Crucially, as emphasized by the PCI Security Standards Council (FAQ 1137), passing a Luhn check confirms only syntactic format compliance; it never proves that a payment card number was actually issued, is active, or belongs to a valid account.2 Note that the paywalled full text of ISO/IEC 7812-1 was not directly inspected; this entry relies on USPTO, PCI SSC, GSMA, ETSI, CMS, and Apache documentation.1245
- 2PCI SSC FAQ 1137: Account Number Validation and Issuance StatusPCI Security Standards Council ↗
- 1US2950048A: Computer for Verifying Numbers (Hans Peter Luhn)Google Patents (USPTO) ↗
- 4ETSI TS 123 003 V18.7.0 (Annex B: IMEI Check Digit)European Telecommunications Standards Institute (ETSI) ↗
- 5NPI Check Digit Technical SpecificationCenters for Medicare & Medicaid Services (CMS) ↗
Frequently asked questions
- What kinds of errors does the Luhn algorithm detect?
- It detects any single-digit entry mistake and most transpositions of adjacent digits, helping catch accidental typing errors before processing.16
- Does passing the Luhn check prove a credit card number is real or active?
- No. Passing the Luhn check only confirms syntactic format compliance; actual card issuance and account status must be verified by the card issuer or payment network.2
- How does the U.S. NPI use the Luhn algorithm differently?
- CMS calculates the NPI check digit as if the 9-digit base were preceded by the prefix 80840 (health + United States), which adds the constant 24 to the digit sum when the prefix is omitted.5
Quotable sentences
Hans Peter Luhn filed U.S. patent US2950048A on July 20, 1954, and the patent was granted on August 23, 1960.
1The Luhn check doubles alternate digits from the right, sums the digits of two-digit products, and passes when the total sum modulo 10 equals zero.
156The algorithm is used for check digits in payment card PANs, mobile IMEIs (GSMA and ETSI TS 123 003 Annex B), and U.S. NPIs (CMS with the 80840 prefix constant 24).
2345Passing a Luhn check confirms only format validity and does not verify whether a payment card or identifier is actually issued or active.
2
Timeline
- Hans Peter Luhn files U.S. patent application US2950048A for a number-verifying computer.1
- U.S. Patent US2950048A is published and granted.1
- CMS publishes the NPI Check Digit specification incorporating the Luhn formula with the 80840 prefix constant (24).5
- ETSI publishes TS 123 003 V18.7.0 detailing the Luhn check digit for mobile IMEIs in Annex B.4
Sources
Government and public records
- 5NPI Check Digit Technical Specification · Centers for Medicare & Medicaid Services (CMS) · published 2004-01-23 · checked 2026-12-04https://www.cms.gov/Regulations-and-Guidance/Administrative-Simplification/NationalProvIdentStand/Downloads/NPIcheckdigit.pdf
Academic and news
- 1US2950048A: Computer for Verifying Numbers (Hans Peter Luhn) · Google Patents (USPTO) · published 1960-08-23 · checked 2026-12-04https://patents.google.com/patent/US2950048A/en
- 2PCI SSC FAQ 1137: Account Number Validation and Issuance Status · PCI Security Standards Council · published 2012-07-01 · checked 2026-12-04https://www.pcisecuritystandards.org/faqs/1137/
- 3IMEI Database Device Manufacturers User Guide (Version 4.0) · GSMA · published 2015-09-01 · checked 2026-12-04https://imeidb.gsma.com/imei/resources/documents/IMEIDB_IA_UserGuide.pdf
- 4ETSI TS 123 003 V18.7.0 (Annex B: IMEI Check Digit) · European Telecommunications Standards Institute (ETSI) · published 2024-09-01 · checked 2026-12-04https://www.etsi.org/deliver/etsi_ts/123000_123099/123003/18.07.00_60/ts_123003v180700p.pdf
- 6LuhnCheckDigit API Documentation (Apache Commons Validator 1.11.0) · Apache Software Foundation · published 2026-01-01 · checked 2026-12-04https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/checkdigit/LuhnCheckDigit.html
Review and writing
Expert review pending
When a credentialed expert reviews this page, the reviewer's name and the review date appear here. (Current version c7aa5de0)
How this page was written
Written automatically from the public information in the sources above.
Version
c7aa5de00608efc4ea4f4128be1960d8fc07274fdebc6e5af8105cf653c3242e
Each edit gives the page a new version number.
Mimirwiki. "Luhn Algorithm." Version c7aa5de0, 2026-12-04. https://mimirwiki.com/wiki/luhn-algorithm
# Markdown curl https://mimirwiki.com/wiki/luhn-algorithm.md # JSON-LD, by content negotiation curl -H "Accept: application/ld+json" \ https://mimirwiki.com/wiki/luhn-algorithm
Add an extension to the address to get the same content in that format.