GB11643-1999 is the national standard for the current citizen identification number in our country. We can easily find this document.
Identity#
The identity card number, also known as the citizen identification number, consists of 18 digits. The identity card number is divided into two parts: the main code and the check code.
Main Code#
The first seventeen digits of the identity card number are the main code (master number), arranged from left to right in the following order: six-digit address code, eight-digit birth date code, and three-digit sequence code. This part is relatively simple, so I will not elaborate on it.
Check Code#
The eighteenth digit of the identity card number is the check code (check number), which can be obtained by performing a specified mathematical operation on the first seventeen digits. Specifically, the MOD 11-2 check code algorithm is used.
MOD 11-2 Check#
First, each digit of the identity card number has its fixed weighting factor $Wi$, which is equal to the remainder when $2$ raised to the power of $18-i$ is divided by $11$. Here, $i$ represents the position of each digit in the number, as follows:
Multiply each digit $a_i$ by its corresponding weighting factor $W_i$ and sum them up to obtain the value $S$:
Calculate the remainder when $S$ is divided by $11$:
Then subtract this remainder from $12$:
Finally, calculate the remainder when this difference is divided by $11$, and obtain the final check code $a_{18}$:
Now that we know the algorithm, let's give it a try (using Appendix A mentioned in the national standard as an example):
Suppose a citizen's identity card number is 11010519491231002X.
We can calculate the weighting factors for the first seventeen digits
Let's take the fifth digit as an example and calculate the weighting factor $W_5$:
$W_5$ should be the remainder when 8192 is divided by 11:
Similarly, after some calculations, we can easily obtain the following table showing the relationship between $W_i$ and $a_i$:
$a_i$ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$W_i$ | 7 | 9 | 10 | 5 | 8 | 4 | 2 | 1 | 6 | 3 | 7 | 9 | 10 | 5 | 8 | 4 | 2 |
Then calculate the value $S$:
Divide 167 by 11, the quotient is 15 and the remainder is 2:
Subtract 2 from 12, the difference is 10. Divide 10 by 11, the quotient is 0 and the remainder is 10:
Therefore, the check code $a_{18}$ is equal to 10. Since the identity card number is limited to 18 digits, we replace 10 with the Roman numeral X. So the check code for this citizen's identity card number is X.
Note: This text is referenced from the following sources:
- National Standard of the People's Republic of China "GB 11643-1999 Citizen Identification Number"
- Wikisource "GB 11643-1999 Citizen Identification Number"