## The Secret Algorithm in Your Credit Card Number

chances are you have a credit card in

your wallet on the front is usually

something like your name and other

information like your bank and the card

carrier like Visa MasterCard etc and a

string of sixteen fifteen or fourteen

numerical digits these digits vary from

card to card and they're enough for

merchants to transact business with your

bank on your behalf

however this string of numbers isn't

random in fact there's a secret code in

there that validates your card and keeps

it safe all in the number structure

it's a low-tech mathematical algorithm

called the loon formula invented by Hans

Peter Luhn in 1954 this mathematical

tool actually dates back to before the

existence of credit cards even with that

fact it's included in every credit debit

an ATM card on earth and it also makes

for a mind-blowing bar trick if people

don't know it here's how you can see how

it works first you'll want to write out

your or any credit card number on a

piece of paper this is a randomly

generated Visa card number so it's not

real you can try but it's not going to

work now once you have that card number

written out you'll double every other

number starting with the second number

from the right and then write them below

that card number like this once you've

done that you'll have a new string of

numbers with every other number doubled

starting from the right after doing that

any two-digit numbers as a result of the

doubling you'll sum both of those

individual numbers together to get a

single number so with our first two

digit number of 16 you'll sum 1 in 6 to

get 7 making a 1 digit number

extrapolating that process out here's

our new string finally at all the

numbers you're left with in the string

doubled and original like below ignoring

the original numbers that you doubled

and now have a new number 4 if your

final sum is divisible by 10 then it's a

valid card number if the final sum isn't

divisible by 10 then the card number

isn't valid or you did something wrong

in the case of our sample number it's

just not in use but it's still a valid

number this algorithm is used to

calculate every single card number on

earth Visa Mastercard Discover they all

have 16 digits and American Express has

15

and then diners club cards have 14 each

different card issuer will have

different subcategories of what numbers

mean in their string like issuer ID

account number etc but they all have to

line up with the lewd algorithm

back to the Loon algorithm itself the

last number in your credit card is

referred to as a check digit as the

computer runs the algorithm it will

complete its sum without the last number

using our sample number as an example

we've replaced the final digit of nine

with an X variable by then completing

the sum were left with a final number of

81 plus X now the computer can look back

at the original number see that the last

digit is in fact nine and when added to

the sum it creates a number divisible by

10 this divisibility by 10 we see in the

Loon algorithm also lends to its

alternative name of modulus 10 or mod 10

the algorithm was originally used to

detect data entry errors and to verify

number strings not as a defense against

fraud however today it functions as a

great first flag for fraud detection

software on credit card issuers internal

systems chances are if the Loon

algorithm doesn't check out there might

be something else at play as well there

are some cases that the Loon algorithm

can't catch so it's not a solve all for

checking credit card numbers but it is

the primary rule that card numbers have

to abide by this algorithm isn't just

used for credit cards either it's also

used in the IMEI cards in cell phones

and commonly in insurance identifier

numbers Ethernet networking also uses a

similar check digit system to ensure

data arrives just like it was sent and

didn't get garbled up along the way

algorithms using Lewton methodology are

seen all across our modern digital

infrastructure and now you can blow some

people's minds at the bar while also

covertly getting their credit card

numbers thanks for watching

you