I apologize if question is too simple!

For example, is the probability of generating 2, 8-digit numbers that have the last 4 digits match the same as the probability of the last 4 matching with a 12 digit number?

For an 8 digit number:

10^8 total possible numbers and 10*10*10*10*1*1*1*1 = 10^4 / 10^8 = 1/10,000 probability of generating 2 with the same last 4.

For 12 digit:

10^12 total possible. 10^8 / 10^12 = 1/10,000 probability again of generating 2 with the same last 4?

Is this correct?

  • $\begingroup$ How are these values generated? Do they come from a uniform distribution? $\endgroup$ Mar 18, 2013 at 22:21
  • $\begingroup$ Sorry, yes uniform distribution. I will add that to the question! $\endgroup$
    – quannabe
    Mar 18, 2013 at 22:27

1 Answer 1



  1. you're generating these values uniformly
  2. an "8 digit number" could have leading 0s (e.g., the number 123 can be written 00000123).

If these assumptions are true, then your answer and you're reasoning are correct.

Here's another way to look at it that might require less arithmetic. Reframe the question: each digit is sampled independently and identically uniformly on $0, 1, \dots, 9$. Then having the last 4 digits match for two 8 digit numbers is the same as the probability of having two 4 digit numbers match exactly (the other digits don't matter since they are independent of the last 4, and we're not interested in whether they match or not). The probability the last 4 digits match is $(1/10)^4$ which is what you wrote above. Taking this same perspective for the 12 digit numbers, it doesn't matter what the first 8 digits are, and you again have $(1/10)^4$ chance of getting matching last 4 digits.

  • $\begingroup$ Thanks! Your reasoning seems simpler than how I was approaching the problem! $\endgroup$
    – quannabe
    Mar 18, 2013 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.