Skip to content

No. 134Numbers3 minviews 28

Published by GK Library Annex

Are the 16 digits on a card number random?

Each part of a card number has a job, including the trick that lets checkout pages spot typos.

A blank white chip card on a leather wallet beside a phone and coffee cup

The 16 digits on a payment card aren't random. The first digits tell you which company issued the card, and the very last digit is a check digit calculated from all the digits before it. That's why, if you mistype even one digit on an online checkout page, it can flag the number as wrong before it ever asks the card company.

The first digits are an address

The international standard ISO/IEC 7812 assigns a role to each part of a card number. The first digit shows the industry, and cards starting with 4 or 5 belong to banking and finance. Typically, a number starting with 4 is Visa and one starting with 51 to 55 is Mastercard. The first six digits are the issuer number that identifies the company that issued the card, and these days that has grown to as many as eight digits.

The digits after that are a unique number for each individual card, and the last digit is the check digit. Not every card has 16 digits, either. American Express cards have 15 digits and start with 34 or 37.

The last digit is calculated

This method is known as the Luhn formula, after IBM researcher Hans Peter Luhn, who filed a patent for it in 1954. Counting backward from the last digit, you double every second digit: the second, the fourth, and so on. If a doubled value has two digits, you add those two digits together to get a single digit. The last digit is then chosen so that the sum of these changed digits and all the remaining digits is a multiple of 10.

So if you mistype a single digit, the total no longer comes out to a multiple of 10 and the mistake is caught right away. It also catches most slips where you swap the order of two neighboring digits. A few mistakes still get through, though, such as typing 90 instead of 09.

A typo check, not a lock

A common misconception is that the last-digit calculation is a security feature that protects your card. The method is public, so anyone can make up a number that fits the rule. This digit only catches typos. Whether a payment actually goes through is decided separately by the card company, which looks at things like the expiration date, the security code on the back, and your credit limit.

You run into this calculation all over everyday life. If a red line appears the moment you finish typing your card number at checkout, this check ran first. When that happens, before you worry that something is wrong with your card, just go back over the number digit by digit. The 15-digit IMEI number assigned to every mobile phone gets its last digit the same way.

The last digit of a card number is a check digit calculated from the others. It catches typos, but it isn't a security feature.

Notes and references · ISO/IEC 7812-1; Luhn, US Patent 2,950,048 (1960). Structure per the international standard; the calculation per Luhn's patent. Starting digits and lengths vary by card network, and a 2017 revision made issuer numbers eight digits.

Editorial standardsReport an error

Quick quiz

What is the main job of the last digit of a card number?

Saved only in this browser.

On the same shelf · Numbers

  1. 10.18NumbersA 60% chance of rain: will it rain or not?views 38 · 4 min
  2. 10.16Numbers30% off plus 20% more: is that half price?views 55 · 4 min
  3. 10.15NumbersFive heads in a row: is tails due next?views 38 · 3 min