Help to make an formula on how to calculate check digit on mod11

Hi,

I am trying to make a formula on how to calculate check digit on mod11 (Modulus11). But i only get errors. I have tried do get the AI to help me create an formula. But that formula also only gets errors. Hope some off you can help me make an formula on this.

Here is an website to explane how you can calculate check digit. MOD 11 Check Digit

Hi @markusos, welcome to the forum! :slight_smile:

Here's an example of how you can calculate it as per the link you shared, I hope it helps you:

(UPDATED)

Enter ID here: {formtext: name=number; default=036532}
The check digit is: {=11 - remainder(sum([d*(remainder(index - 1, 9)+2) for (d, index) in split(reverse(number), "")]), 11)}

Hi, tank you so much :slight_smile: But I can see that this only work for numbers that are seven digits or shorter. For exambel for 9140800742 the correct check digit is 4. But the formula gives me 6. Can you please check if you can fix that? And again thank you so much :slight_smile:

@markusos I updated the formula to reset the multiplier to 2 when exceeding 10, but still 9140800742 gives 1 as the check digit, not 4. As far as I understand from the link you shared, we should use a multiplier of 2, 3, ...., 9, 10, then reset the multiplier back to 2 starting from the 10th digit. Please correct me if I'm wrong, or elaborate on how 9140800742 is evaluated to 4, so that I can fix the formula once more.

Hi, here you have the math behind it:

9140800742:

9 x 5 = 45
1 x 4 = 4
4 x 3 = 12
0 x 2 = 0
8 x 7 = 56
0 x 6 = 0
0 x 5= 0
7 x 4 = 28
4 x 3 = 12
2 x 2 = 4

45 + 4 + 12 + 0 +56 + 0 + 0 +28 +12 + 4 = 161

161 / 11 = 14,63

14 * 11 = 154

161 - 154 = 7

11 - 7 = 4

I think maybe what is wrong is that the weight number should not be higher than 7. And then it should start at 2 again. And the number you get after dividing by 11. In this example 14,63 should always be round down.

@markusos I changed the formula as per your explanation, I hope it works for you now.

Enter ID here: {formtext: name=number; default= 9140800742}
The check digit is: {=11 - remainder(sum([d*(remainder(index - 1, 6)+2) for (d, index) in split(reverse(number), "")]), 11)}

1 Like

Again thank you so much for your help :slight_smile:

1 Like