How To Generate *Valid* Credit Card Numbers

by golbguru on April 12, 2007

What do the credit card numbers mean and how are they generated? I need to start with a disclaimer: Do not use any credit card numbers, except your own, to buy things off internet. It’s wrong and it’s illegal. The purpose of this post is *not* to create fraudulent workable card numbers. It is to explain the math and the science behind those numbers that most of us see day in and day out; and hence this post should be viewed from a purely academic perspective.

Typical credit card anatomy

Before we understand how credit card numbers are generated, here is a brief explanation of what a typical credit card number means.

credit card number anatomy

  • Out of the 16 numbers on a typical credit card, the set of first 6 digits is known as the issuer identifier number (read this for details), and the last digit is known as the “check digit” which is generated in such a way as to satisfy a certain condition (the Luhn or Mod 10 check). “Luhn check” is explained later in this post. The term sounds intimidating, but it’s really a very simple (and elegant) concept.
  • Taking away the 6 identifier digits and 1 check digit leaves us with 9 digits in the middle that form the “account number”.
  • Now, there are 10 possible numbers (from 0 to 9) that can be arranged in these 9 places. This gives rise to 109 combinations, that is, 1 billion possible account numbers (per issuer identifier).
  • With each account number, there is always an unique check digit associated (for a given issuer identifier and an account number, there cannot be more than one correct check digit)
  • Amex issues credit cards with15 digits. The account numbers in this case are 8 digit long.

What is the “Luhn” or “Mod 10″ check?

In 1954, Hans Luhn of IBM proposed an algorithm to be used as a validity criterion for a given set of numbers. Almost all credit card numbers are generated following this validity criterion…also called as the Luhn check or the Mod 10 check. It goes without saying that the Luhn check is also used to verify a given existing card number. If a credit card number does not satisfy this check, it is not a valid number. For a 16 digit credit card number, the Luhn check can be described as follows:

  1. Starting with the check digit, double the value of every second digit (never double the check digit). For example, in a 16 digit credit card number, double the 15th, 13th, 11th, 9th…digits (digits in odd places). In all, you will need to double eight digits.
  2. If doubling of a number results in a two digit number, add up the digits to get a single digit number. This will result in eight single digit numbers.
  3. Now, replace the digits in the odd places (in the original credit card number) with these new single digit numbers to get a new 16 digit number.
  4. Add up all the digits in this new number. If the final total is perfectly divisible by 10, then the credit card number is valid (Luhn check is satisfied), else it is invalid.

When credit card numbers are generated, the same steps are followed with one minor change. First, the issuer identifier and account numbers are assigned (issuer numbers are fixed for a given financial institution, whereas the account numbers are randomly allocated - I think). Then, the check digit is assumed to be some variable, say X. After this, the above steps are followed, and during the last step, X is chosen in such a way that it satisfies the Luhn check.

This part is a bit confusing and takes some time to understand. However, don’t get stuck here…continue reading through the examples below and you will figure out what this is all about.

Credit card numbers valid or invalid?

Have you ever wondered if those numbers on the fake plastic or cardboard credit cards that come with the “preapproved” offers are real or imaginary? If they are not valid, how do you know it?…Just apply the Luhn check and all the those fake credit cards will invariably fail.Here is an example of a VISA credit card (look at the expiry date - 01/09’s still valid ! ;) )

visa credit card

Note that the credit card number starts with “4″…so it is indeed a VISA issued credit card (VISA cards start with “4″ and MasterCard/Maestro cards start with “5″). Now, let us apply the Luhn algorithm to this card. To make it easier on you guys, I have created a schematic of the steps towards the Luhn check (below) for this card number 4552 7204 1234 5678:

luhn visa credit card calculation

  • In this case, when we sum up the total, it comes to 61 which is not perfectly divisible by 10, and hence this credit card number is invalid.
  • If such a credit card number is ever generated, the value of the check digit would be adjusted in such a way as to satisfy the Luhn condition. In this case, the only value of the check digit, that will create a valid credit card number, is 7. Choosing 7 as the check digit will bring the total to 60 (which is perfectly divisible by 10) and the Luhn condition will be satisfied. So the valid credit card number will be 4552 7204 1234 5677.

Let’s try another example, this time with a MasterCard.

MasterCard credit card number verification

Again, performing the Luhn check on this credit card number, we have:

Mastercard credit card numbers

  • The total comes to 65 which is not perfectly divisible by 10. Hence this credit card number is invalid.
  • In this case, a valid credit card number will result only if the check digit is 8. This will bring the total to 70 which is perfectly divisible by 10. So the valid credit card number will be 5490 1234 5678 9128.

Closing remarks

If I still have your attention, here are some additional thoughts. In the context of this post, by the term “valid”, I mean “mathematically valid”. A mathematically valid credit card does not mean a “working” credit card. The Luhn formula validates only the credit card number; it does not validate the expiry date and/or card security code (CVV, CVC). Plus, as discussed before, the 9 digit account number will yield 1 billion combinations; so the chances of getting a working credit card number are very remote. It should also be noted that, this validation is usually employed at the transaction end; which means that numbers that do not satisfy the Luhn check are not forwarded to the card issuer and the transaction is terminated. If you have a fake credit card which satisfies the Luhn check, it will go through at the transaction end, but the card issuer will most likely catch the mischief. So don’t go about trying to use these numbers to buy stuff.

Just to be clear on this, I don’t expect comments like these (check out the source of this comment):

hey. im hearing good things about your site! i need some money to jump start my poker career. Probably about 40-100$ would do. i dont have a credit card to use and it pisses me off because i know i could beat the majority of the people online. please help

If you intend to post such comments, at least be extremely funny. :)

So you think you can separate out valid and invalid account numbers now? Here are a couple of trial numbers for you:

  • 5491 9469 1544 4923 - Valid or invalid? If invalid, what should have been the correct check digit to make it valid?
  • 4539 9920 4349 1562 - Valid or invalid? If invalid, what should have been the correct check digit to make it valid?

Sudoku fans will quickly figure out multiple valid combinations of the above numbers. If you don’t want to do the math, here are some ready made valid (”test”) credit card numbers from Paypal.By the way, the Luhn check is also valid for debit card numbers.I am still in the learning phase with this topic and trying to further understand how people use (or misuse (?)) such information. If you have some insight in this matter, please feel free to share it with us.If you liked what you read above, go ahead and subscribe to this blog to get more updates. It’s easy - just click on one of the buttons below and get the feed. :)

Add to Google Reader or Homepage
Resources and References

There is a vast amount of literature on the Luhn algorithm and a quick Google search will enlighten you on how popular this topic is. If you don’t want to read all that, here are links to some interesting reading.

VISA card image source:, MasterCard image source:

Related Articles:

{ 3 trackbacks }

April 13th Friday Five - Friday the 13th Edition : Generation X Finance
04.13.07 at 10:04 am
Money Articles: Want To Know How To Double Your Money? Why Not Triple It? » Silicon Valley Blog About Money
04.14.07 at 7:31 am
Posts I Enjoyed Last Week | The Sun’s Financial Diary | A Personal Finance Blog on Saving and Investing
04.15.07 at 5:20 am


1 Moneymonk 04.12.07 at 9:02 am

Nice observation. I never knew that. In the world of pf blogging, I learn something new everyday.

2 tanyetta 04.12.07 at 9:58 am

is there a formula for the winning lottery numbers? if so, please share :)

p.s. great blog love love love it! thanks.

3 plonkee 04.12.07 at 10:22 am

ISBN numbers on books use a similar algorithm to determine if they are valid. These error checking codes are real (pure) mathematics and part of Coding Theory (not to be confused with Cryptography) which I no longer remember much of from University.

4 Denivic 04.12.07 at 9:22 pm

Thanks for the insight; your information was very valuable. I was able to calculate the first group of numbers and it’s not considered valuable, rather “it’s not a valid credit card number.” For it to be consider a valid number the check digit have to be a “7 or 0” Moreover, the second credit card number is valid, if of course it was issued to Visa Merchant card company and activated. Good work providing this material to us and passing the knowledge. I have to point out a small error. For example, you give us credit card number 4452 7204 1234 5677, but on the schematic you gave us 4[5]52 7204 1234 5677. So actuality we would get two different sums. The total of the sum given was 61, so my guess is you wanted to use the credit card number you plug into the schematic.


5 golbguru 04.12.07 at 9:33 pm

Moneymonk: I am learning new things everyday too. :) It’s a lot of fun blogging about financial stuff. :)

Tanyetta: Yes, for lottery numbers, I will charge you $100 per number. ;) ..just kidding.

: thanks for mentioning that…I guess the rest of my day will go into looking for ISBN numbers now.

Denivic (young): I am glad you worked out the examples. That serves my purpose. I just wanted to put it out there, so that, in future, if anyone asks you about “Luhn” formula…you will be able to explain things nicely using a credit card. :)

Thanks for pointing out the typo. It’s now corrected. The correct number is 4552 7204 1234 5677.

6 3 Things About Money 04.13.07 at 4:35 am

That is so cool, I learn something new from you every day. My work break for today is going to be working out the test questions you included. Actually, there might be a really good application in my work to generate valid codes for samples…hmmmm…thanks!

7 credit card owner 04.16.07 at 12:57 am

Shoot, this is way too complicated for me. The only thing I understood was that this munber is based on certain algorythms. So if you know them you might be able to guess somebodies credit card number. Is it right?

8 ackah micheal 04.16.07 at 10:48 am

hello, i will be so happy if i can be granted a valid credit card thanks so much.

9 Glenn Rhea 04.16.07 at 1:16 pm

Hi. The information you provided was insighful. I have another question regarding gift cards. Is there an industry standard for gift cards? How do retailers “choose” the numbers they print on their gift cards?


Glenn R.

10 Roy Gerbil 04.16.07 at 3:06 pm

I read over this 4 times now and I’m still barely grasping it. Still, great article!

11 golbguru 04.17.07 at 12:48 am

3 things about money: I am glad you found some use for it.

Credit card owner: If you try it out on your own credit won’t be too difficult to figure out how this works. You cannot guess “somebody’s” credit card number…you can just generate a mathematically valid credit card number. There is a probability (albeit nearing zero) that the number you generate might be someone’s credit card number. However, that’s not the aim…learning about some fundamentals is the aim. :)

ackah micheal: Yeah, you bet! I will be happy to get one too.

Glen Rhea
: I will check out what goes on with gift cards and get back to you. Probably there is some algorithm, but I am not sure it’s the Luhn algorithm.

Roy: I guess it will be clearer if you take your own card and follow the steps. Sometimes, experiments are better understood than theory.

12 smith 04.17.07 at 3:28 am

i want to know the algorithm used or required in getting the validity dates including the billing address of a valid cards

thank you

13 boss 04.17.07 at 4:52 am

i need a credit card for my air ticket booking

14 mourya 04.18.07 at 2:45 am

what about generating the cvv of the credit card number we genterated…and its expiry date and othe details that are necessary to make online shoppings…in sites like (url deleted) etc.,

15 Wajahat 04.18.07 at 4:40 am

hey pretty good information. but one more thing how is security code generated. it is common but no one published over security code. do u have any knowledge. plz mail me on
waiting for ur reply.

16 Amit 04.25.07 at 12:09 pm

Is there anything that will generate the 3-digit CVV code with 16-digit credit card number.

17 neo 04.28.07 at 5:31 am

thanks for the info but you need to tell us about the other details like “expire data ” ect..
but let’s say I generated valid numbers and valid details how does the page check this info let’s say I have not enough money how does it know about it????

18 M.javed 05.04.07 at 12:39 am

I give your valid card number to a website. That website want to confirm my age. But both the time it replay me that the card number is not valid.

19 golbguru 05.04.07 at 12:57 am

People: Let me re-state the objective of the post:

The purpose of this post is *NOT* to create fraudulent workable credit card numbers. It is to explain the math and the science behind those numbers that most of us see day in and day out; and hence this post should be viewed from a purely academic perspective.

Do not use any credit card numbers, except your own, to buy things off internet. It’s wrong and it’s illegal.

20 TheMan2008 05.04.07 at 9:35 am

plzzzzzzzzzzz tell me where to get more numbers ??? i have got 5 working credit card numbers from here 2 visa 3 master card where do i get more ????? :P

21 TheMan2008 05.04.07 at 9:37 am

i no it’s illegal i won’t buy anything with them i no it can get me to jail :(

22 TheBigMan 05.04.07 at 11:41 am

That is all cool. What do I use as the CVV number for my ‘valid’ number?

23 seth 05.07.07 at 10:47 am

dear sir,
please am an overseer of an orpahnge school. i have run out of money and i really need your help to provide me a credit card in other to assist me finace the poor orphans their basic needs.
Dr. seth

24 APollo 05.16.07 at 7:13 am

Great in-depth article, I have some excellent cc generators if anyone wants them you can drop me a msg at

25 COMPTON 05.20.07 at 11:11 pm

Please help me for free by giving me a valid cc n° (out of date or account empty is ok). I’m a full time volunteer for JARDINS FELINS a young charity in France helping stray cats. I need to download an e-book . It is free for 7 days and the order can be cancelled by email so no demand will be made on the cc. OR can YOU download the book and forward it to me ?
E-book is at

26 Arch 05.23.07 at 11:13 pm

Can i have also that if its ok ill try it..

tnx just send it to my email..

27 Arch 05.23.07 at 11:16 pm
28 Lil 06.02.07 at 10:12 am

Thanks for the article! I knew there’s a validity check for ISBN #s but I didn’t know it for credit cards!

29 MANISH 06.05.07 at 1:28 am

can you give me a credid card i want to buy a booki it is woth $8.20 only. can any body help me

30 heewon kim 06.10.07 at 12:24 am

i know a hack to get small lists of valid credit card numbers, but i’m only willing to share if i am also benefitted.
email me,

31 MANISH 06.12.07 at 1:12 am

hi heewon pls advice me i hv mailed u

32 kade 06.22.07 at 3:36 am

hi! ..can u shared ur credit card number…
i just want to see more vedios from defloration ….its all about virginity..i want to see the vedio…they need credit card number….help me…hehehhe…just send in my e-mail …thnxxx

33 faizankhan 07.07.07 at 3:28 pm

dear sir
i am really poor guy. iam looking for small amount for the purpose of starting small business so kindly send me the valid card numbers thank u i am waiting ur reply

34 Da Man 07.10.07 at 7:05 pm

Hi ya Great Article!!!

At least Now i know how The credit card number works. But How is the Security Code Generated.

Ppl dis isn’t a place to make up some story to get money but if u r going to do that you may as well visit this site;

Heres some CC numbers


5565552064481449 - 2354
5301745529138831 - 9823
5311531286000465 - 7364
550093917800 4613 -8847
5597507644910558 - 7687
5155557247383442 - 8903

35 Oh whatever 07.12.07 at 1:04 pm

Thanks for the info it was verry useful and wel explained ;)

36 gina hare 07.13.07 at 8:34 am

please i need a valid credit card to buy some things.thank you

37 MC K 07.17.07 at 12:45 am


38 master theif 07.20.07 at 1:51 am

ive created over 80 valid credit card numbers if u want one hit me up on my aim sreenname zerotwiztidsk8er

39 JP 07.20.07 at 12:22 pm

master thief i need some credit card number man u mind passing soem on to me

40 JP 07.20.07 at 2:46 pm

well you will see my previous message send me credit card numbers and tell me if they are visa mc American express and etc…

my email is

thanks JP

41 common 07.22.07 at 2:39 am

can u give me a valid credit card number cuz i need a mmorpg game and u need 2 buy it online cuz i cant find a store and i dont have a credit card….my email is

Comments on this entry are closed.