How Spain's DNI and NIE check letters are calculated using modulo 23
Spanish national ID numbers (DNI) include a final control letter derived from a simple mathematical operation: dividing the 8-digit number by 23 and mapping the remainder to a fixed 23-letter table published by the Interior Ministry. Four letters — I, O, Ñ, and U — are excluded from the table to avoid visual confusion and to keep the total at 23, a prime number that enables error detection. Foreign resident IDs (NIE) follow the same logic, but their leading letter (X, Y, or Z) is first substituted with 0, 1, or 2 respectively before applying the same modulo calculation. The current NIE format was standardised by Order INT/2058/2008, which introduced the nine-character structure and defined the sequential use of Y and Z as the X series became exhausted. The control letter can catch single-digit typos and transposition errors, though it does not verify whether the document actually exists in any official registry.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in