Your cart is empty
Shop now
+

Luhn Algorithm Test: How to Check a Number

Explore

Luhn Algorithm Test: How to Check a Number

We guarantee gift cards direct to your inbox immediately.
Shop Now!

Let's Work Together

Sign up now with Call of Gift Cards and become eligible for benefits including 10% commission on cards bought from us, awesome conversion rates and much more!
Find Out More

Digital Gift Cards

The market for digital goods and services are growing rapidly. One of the true shifts in online behaviour is the switch from traditional direct online payments and purchase to wallets and gift cards. ...read more
+

Digital Gift Cards

The market for digital goods and services are growing rapidly. One of the true shifts in online behaviour is the switch from traditional direct online payments and purchase to wallets and gift cards. We invite you to start your own online business as a partner of ours. By signing up as a partner you’ll get access to one of the largest gift card databases in the world. All you need to focus on is to market your website and products. Gift cards are quickly outperforming traditional gifts, as they give the recipient the choice to pick their own present from a variety of options. The range of e-gift cards available on the Call of Gift Cards's partner sites includes popular categories such as restaurants, games, travel and fashion.

Gift Vouchers

Traditional gift vouchers are printed paper gifts available in set values that can be spent in specific stores. Open-loop, semi-open loop, and closed-loop are often terms used when referring to gift v...read more
+

Gift Vouchers

Traditional gift vouchers are printed paper gifts available in set values that can be spent in specific stores. Open-loop, semi-open loop, and closed-loop are often terms used when referring to gift vouchers. All gift cards sold via our partners’ websites are closed loop. This means that the gift card can only be spent at a single brand location, for example, an Xbox voucher can only be spent at Xbox etc.

Our Gift Cards

Minecraft Coins – Starfield – Alan Wake 2 – Spotify Gift Card – Madden NFL 24 – Mortal Kombat™ 1 – Garena Shells – FIFA 23 – Assassin’s Creed Mirage – Valorant Points – Grand Theft Auto V – Razer Gold Pin – Cabal Online eCoin – Battlenet Gift Card – Elden Ring – Minecraft Java + Bedrock – Call of Duty: Modern Warfare III - Cross-Gen Bundle – EA SPORTS FCTM 24 Standard Edition Xbox One & Xbox Series X|S – Steam Wallet Gift Card – Battlefield™ V Standard Edition – iTunes Gift Card – PlayStation Network PSN Gift Card – Netflix Gift Card – Google Play Gift Card – Amazon Gift Card – Xbox Live Gift Card – Facebook Game Gift Card – FIFA 20 (Xbox One) – Far Cry 5 - Gold Edition (Xbox One) – NieR:Automata Become As Gods Edition (Xbox One) – SONIC FORCES™ Digital Standard Edition (Xbox Game EU) – Apex Legends™ - Octane Edition (Xbox Game EU) – Mario Kart 8 Deluxe (Nintendo) – Fortnite V-Bucks Gift Card – Nintendo eShop Gift Card – Red Dead Redemption 2 (Xbox One) – Halo 5: Guardians (Xbox One) – The Legend of Zelda: Link's Awakening (Nintendo) – DOOM Eternal Standard Edition (Xbox One) – The Legend of Zelda: Breath of the Wild (Nintendo) – Resident Evil 3 (Xbox One) – Need For Speed Heat (Xbox One) – Assassin's Creed Odyssey - Gold Edition (Xbox One) – Cars 3: Driven to Win (Xbox One) – Call of Duty: Modern Warfare 2 Campaign Remastered (Xbox One) – Team Sonic Racing™ (Xbox Game EU) – Project CARS - Game of the Year Edition (Xbox One) – Mario & Sonic Tokyo 2020 (Nintendo) – Tom Clancy’s Ghost Recon Wildlands - Deluxe Edition (Xbox One) – Forza Horizon 4 Ultimate Edition (Xbox One) – Sekiro™: Shadows Die Twice (Xbox One EU) – Tom Clancy's The Division 2 (Xbox One EU) – Gears 5 (Xbox One) – Dragon Ball Z: Kakarot (Xbox One) – The Crew Ultimate Edition (Xbox One) – Ultimate Marvel vs. Capcom 3 (Xbox One) – Pokemon Let's Go Eevee! (Nintendo) – Sonic Mania (Xbox Game EU) – UFC 3 - Deluxe Edition (Xbox One) – Mass Effect Andromeda - Standard Recruit Edition (Xbox One) – BioShock: The Collection (Xbox One) – A Way Out (Xbox One) – Borderlands 3 (Xbox One) – Overcooked! 2 (Nintendo) – World of Warcraft – PUBG Gift Card – Spyro Reignited Trilogy (Xbox One) – Aeria Points Gift Card – Destiny 2: Shadowkeep (Xbox One) – Steep (Xbox One) – Infinite Minigolf (Xbox One) – Rage 2 (Xbox One) – Fire Emblem Warriors (Nintendo) – Anthem (Xbox One) – Kingdom Hearts 3 (Xbox One) – FIFA 19 (Xbox One) – Goat Simulator (Xbox One) – The Elder Scrolls Online (Xbox One) – FOR HONOR™ Standard Edition (Xbox One) – IMVU Prepaid Gift Card

Luhn Algorithm Test: How to Check a Number

Short answer

The Luhn test is a check digit test. It reads a number from right to left, doubles every second digit, adds those results to the digits it left alone, and checks whether the total divides by 10. A total that ends in 0 means the number passes. Any other total means the number fails.

What the Luhn test checks

The Luhn formula was published by Hans Peter Luhn in 1954. It catches any single mistyped digit and most swaps of two adjacent digits. It is a format check and nothing more. A pass confirms that the digits are internally consistent. It does not confirm that an account exists, that a card is live, that funds are available, or that a device is registered to anyone.

Prerequisites

  • The number written as a string of digits, with spaces and dashes removed.
  • A calculator, spreadsheet, or short script for the arithmetic.

How to run a Luhn test

  1. Write the digits in a row and drop every space, dash, and separator.
  2. Start at the rightmost digit and move one position left at a time.
  3. Double every second digit you meet, beginning with the second digit from the right.
  4. Subtract 9 from each doubled value that is greater than 9.
  5. Add the adjusted doubled values and the untouched digits into one total.
  6. Divide the total by 10 and look at the remainder. A remainder of 0 means the number passes; any other remainder means it fails.

Worked example

Take the number 79927398713. Reading from the right, the digits in odd positions from the right are 3, 7, 9, 7, 9, 7 and they stay as they are. The digits in even positions from the right are 1, 8, 3, 2, 9, 9 and they get doubled: 2, 16, 6, 4, 18, 18. Values above 9 lose 9, which turns 16 into 7 and each 18 into 9. The adjusted row is 3, 2, 7, 7, 9, 6, 7, 4, 9, 9, 7. Those digits add to 70. Since 70 divides by 10 with no remainder, the number passes.

Generating the check digit

  1. Take the payload digits and leave the last position empty for the check digit.
  2. Start at the rightmost payload digit and double every second digit moving left.
  3. Subtract 9 from every doubled value above 9.
  4. Add all the values to get the payload sum.
  5. Find the smallest number between 0 and 9 that lifts the payload sum to a multiple of 10.
  6. Place that number in the last position as the check digit.

For the payload 7992739871 the values add to 67. The next multiple of 10 is 70, so the check digit is 3 and the full number becomes 79927398713.

Where the Luhn test applies

  • Payment card numbers use a Luhn check digit in the final position of the primary account number, as specified in ISO/IEC 7812.
  • IMEI numbers on mobile devices carry a Luhn check digit.
  • The National Provider Identifier used in United States healthcare carries a Luhn check digit.
  • Canadian Social Insurance Numbers and several national identity and account schemes use the same formula.
  • Form validation libraries apply the test to catch typos before a number is submitted.

Limits of the test

The Luhn formula has a known blind spot: it misses the transposition of the two-digit sequence 09 and 90, and it misses some double errors. It also says nothing about the rest of a number's structure. A payment card number carries an issuer identification number and a length rule that the Luhn test does not evaluate, and the three or four digit security code printed on a card is not part of the Luhn calculation at all. Two different numbers can pass the test while only one of them is issued to anyone, so a pass is a statement about arithmetic, not about validity in the real world.

What's New

Why I Can't Write a CVV Buying Guide

I can't write a buying guide for CVVs or stolen card data. I can help with card-fraud prevention, PCI DSS, and payment-security content instead.

Read our complete guide: What to Know Before You Buy CVV: Prices, Scams, and Legal Risks