# The mod97 operation in IBAN validation

The international bank account number(IBAN) is validated by a $\bmod 97$ operation. Suppose an account number is like sd1234abcd78965h then the following steps are performed:

1. the first four characters of the IBAN number are pulled out from the beginning and are appended at the end of the string.

2. All the letters in the hence obtained string of characters are replaced by the ASCII value of their corresponding uppercase letter decreased by $55$. (ascii value $-55$)

3. The modulus of the hence obtained number, let's say $x$, with respect to $97$ is checked.

4. If the modulus is $1$, then it's a valid IBAN number .

For the third step, Wikipedia mentions an algorithm, which goes as follows:

https://en.wikipedia.org/wiki/International_Bank_Account_Number#Modulo_operation_on_IBAN

A nine digit number is formed by taking the leftmost $9$ digits of $x$. The mod of this number with respect to $97$, $r$ is obtained. Then another nine digit number, $q$ is formed by concatenating $r$ and the next $7$ digits of the number. This process is continued till the last value of $q\bmod 97$ is obtained. If it is $1$ then that validates the number .

But, I couldn't prove that a number, $n$, for whom $n \bmod 97$ is $t$ where $t$ is in between $1$ to $96$, when subjected to above algorithm, will in the end yield $t$. Or is this a special case for numbers $n$ for whom $n\bmod 97$ is $1$? Can you show me a proof of this algorithm or disprove it?

The algorithm works because $a\equiv a'\pmod {97}$ implies that also $$a\cdot 10^k+b\equiv a'\cdot 10^k+b\pmod{97}$$
• If $x<10^9$ then $x<2^{31}$ so that the numbers fit into signed 32 bit integers – Hagen von Eitzen Sep 7 '16 at 17:56