Skip to content
Slipwise
← All posts

What a mod 97 check digit actually does

Slipwise Team · 27 October 2026 · 5 min read

Every Serbian bank account number ends in two digits that carry no information about the account itself. The same is true of the two digits right after the country code in every IBAN. These are check digits, and they exist for one reason: to catch typos before money goes to the wrong place.

Both use the same algorithm, ISO 7064 MOD 97-10. Here is how it works, with real arithmetic you can check yourself.

The idea in one sentence

Choose the check digits so that the whole number, read as one large integer, leaves a remainder of exactly 1 when divided by 97.

That is it. To validate a number, you divide by 97 and look at the remainder. If it is 1, the number is consistent. If it is anything else, at least one digit is wrong.

Serbian account numbers

A Serbian account number has 18 digits, usually printed with dashes:

  • 3 digits: bank code
  • 13 digits: account number within the bank (padded with leading zeros)
  • 2 digits: control digits

The control digits are calculated as:

control = 98 - ((first 16 digits × 100) mod 97)

Multiplying by 100 makes room for the two control digits at the end. Subtracting from 98 is what forces the final remainder to be 1.

A worked example

Take bank code 160 and account 0000000123456. The first 16 digits are 1600000000123456. Multiply by 100 to get 160000000012345600.

That number is too long for most calculators, so reduce it in chunks. Take a few digits, find the remainder, write the remainder in front of the next digits, and repeat:

Step 1:  160000000 mod 97 = 52      (97 × 1649484 = 159999948)
Step 2:  520123456 mod 97 = 47      (97 × 5362097 = 520123409)
Step 3:       4700 mod 97 = 44      (97 × 48      = 4656)

control = 98 - 44 = 54

Account: 160-0000000123456-54

The chunk trick works because remainders carry through multiplication and addition: you only ever need the remainder so far, not the whole number.

To verify, take all 18 digits, 160000000012345654, and divide by 97. The remainder is 1. The account number is valid.

IBANs use the same check

An IBAN puts a two-letter country code and two check digits in front of the domestic account number. To validate one:

  1. Move the first four characters (country code and check digits) to the end.
  2. Replace each letter with a number: A = 10, B = 11, and so on up to Z = 35.
  3. Treat the result as one large integer and compute mod 97.
  4. The IBAN is valid if the remainder is 1.

The example account as an IBAN

Serbian IBANs are RS, two check digits, then the 18-digit account. For our account the IBAN is RS35160000000012345654.

Move RS35 to the end: 160000000012345654RS35. Replace R with 27 and S with 28: 160000000012345654272835. Divide by 97, and the remainder is 1.

Here is a curious side effect. Because every valid Serbian account number already leaves a remainder of 1, the IBAN check digits come out the same for every valid Serbian account: 35. If you see a Serbian IBAN that does not start with RS35, something is off.

What it catches

The strength of mod 97 comes from 97 being a prime number that shares no factors with 10 or with any single-digit difference.

Every single-digit error. Change any one digit and the number shifts by that difference times a power of ten. Since 97 is prime and does not divide any power of ten, and the difference is between 1 and 9, the shift can never be a multiple of 97. The remainder always changes. In our example, changing the last account digit from 6 to 7 (160000000012345754) gives a remainder of 4 instead of 1.

Every swap of two adjacent digits. Swapping neighbors a and b changes the number by 9 × (a - b) times a power of ten. None of those factors is divisible by 97, so this is always caught too. Swapping the 3 and 4 in our account (160000000012435654) gives a remainder of 82.

Most other errors. Two random wrong digits, a swap of non-adjacent digits, or a digit dropped and another added will almost always produce a wrong remainder. With 97 possible remainders, a random corruption slips through roughly once in 97 tries.

What it does not catch

A check digit only proves that a number is internally consistent. It cannot tell you whether it is the right account. A fraudulent invoice with a different, perfectly valid account number passes the check every time. So does an honest invoice where the supplier printed someone else's account.

That is why validation is a first filter, not the whole control. It stops typos and misreads cold. Confirming that an account really belongs to the supplier still needs a human and a trusted source.

Slipwise runs the mod 97 check on every account number and IBAN it extracts from an invoice, and flags any that fail before a teammate is asked to approve the payment.