How to calculate the last digit of PAN?

As per this article on Cleartax, the last digit of a PAN Number is a “alphabet check digit”. Check digits are added to a number to catch transcription errors, and it depends entirely on the original number.

Does anyone know the formula for calculating this last digit if I have the first 9 digits of a PAN?

P.S. Please don’t ask why I am doing this. As a trader, I have lots of free time on weekends, so need something to occupy my brain.

3 Likes

It might not always be 1 possible solution. In credit/debit card numbers also check digits are present.

They are meant to catch one-off typing errors, not to reverse engineer. So more than one value might be correct.

I think the 10th digit can be determined with certainty by the first 9 digits. This is because I have tried a few 9 digit combinations, and for every single one of them, I only found one value for the last digit that can make a valid PAN number.

I found this on Quora but I’m not sure if it’s accurate.

The last character of a PAN (Permanent Account Number) card in India is a check digit, which is calculated using a specific algorithm based on the first 10 characters of the PAN. Here’s how it’s done:

Structure of PAN: The PAN is a 10-character alphanumeric code formatted as AAAAA9999A. The first five characters are letters, the next four are digits, and the last character is a letter.
Assigning Values: Each character is assigned a numerical value:

  • For letters (A-Z), the value is calculated as follows:
    A = 1, B = 2, C = 3, …, Z = 26
    For digits (0-9), the value is simply the digit itself.
    Weighting Factors: Each character is assigned a weight based on its position in the PAN:
  • The weights are as follows: 1, 2, 1, 2, 1, 2, 1, 2, 1, 2.
    Calculating the Check Digit:
  • Multiply each character’s value by its corresponding weight.
  • If the result of the multiplication is a two-digit number, sum the digits of that number (e.g., for 14, you would take 1 + 4 = 5).
  • Sum all these single-digit results.
    Modulus Operation: Take the total sum and compute the modulus 26 of that sum. The result will give you a number between 0 and 25.
    Mapping to Letters: Convert the result of the modulus operation to a letter:
  • 0 = ‘A’, 1 = ‘B’, 2 = ‘C’, …, 25 = ‘Z’.
    The resulting letter is the last character of the PAN.

Example:

For a PAN ABCDE1234F:

  • Calculate values: A=1, B=2, C=3, D=4, E=5, 1=1, 2=2, 3=3, 4=4.
  • Apply weights:
  • (11) + (22) + (31) + (42) + (51) + (12) + (21) + (32) + (4*1) = 1 + 4 + 3 + 8 + 5 + 2 + 2 + 6 + 4 = 35
  • Modulus operation: 35 % 26 = 9.
  • Convert to letter: 9 corresponds to ‘J’.

So, the last character of this PAN would be ‘J’, making the complete PAN ABCDE1234J.

This algorithm ensures that the PAN number is unique and helps in verifying the authenticity of the PAN card.

I think that’s how the check digit works, i.e., it should remain the same for the same string of characters. If not, the purpose of check would be defeated.

I don’t think the check digit can be a random number, but rather a fixed value, which will be arrived based on an algorithm that considers all characters/digits in the given string, to arrive at the final check digit.

I think it is called the Luhn algorithm

What is PAN Check Digit and How it Works? - GeeksforGeeks.

2 Likes

Right
It’s interesting. Got some new info today because of @iankurseth :smiley::+1:t2:

2 Likes

No, this one doesn’t work. But the actual algorithm can be something similar.

I am guessing they will probably use A=10, B=11 and so on as it goes in hexadecimal and just extend it to Z=35. And likely assign special weightage to the 4th (PAN Holder’s status) and 5th (PAN Holder’s Last Name) digits.

Also, I have observed among the few hundreds PAN numbers I have found, that the last digit is always one of ABCDEFGHJKLMNPQR. It looks like they chose the first 16 digits, but ignored I and O because they look similar to 1 and 0.

This is for personal PAN numbers, where the 4th digit is P. Someone please correct me if your PAN number ends with a digit.

Edit: Found some PANs that end with GH
Edit: Found some PANs that end with AB

It may be possible, and then use modulo 35 to determine the last digit :thinking: