Talk:Luhn mod N algorithm: Difference between revisions
Appearance
Content deleted Content added
Mark viking (talk | contribs) Added maths banner |
→Problems if N is odd: new section |
||
Line 1: | Line 1: | ||
{{maths rating|class=start|importance=low|field=number theory}} |
{{maths rating|class=start|importance=low|field=number theory}} |
||
== Problems if N is odd == |
|||
While implementing this algorithm, I noticed an interesting property for odd N: |
|||
Consider the case of base-9. For doubled positions, this occurs: |
|||
{| class="wikitable" |
|||
|- |
|||
! Original digit !! Doubled !! Reduced |
|||
|- |
|||
| 0 || 0 (00<sub>9</sub>) || 0 |
|||
|- |
|||
| 1 || 2 (02<sub>9</sub>) || 2 |
|||
|- |
|||
| 2 || 4 (04<sub>9</sub>) || 4 |
|||
|- |
|||
| 3 || 6 (06<sub>9</sub>) || 6 |
|||
|- |
|||
| 4 || 8 (08<sub>9</sub>) || 8 |
|||
|- |
|||
| 5 || 10 (11<sub>9</sub>) || 2 |
|||
|- |
|||
| 6 || 12 (13<sub>9</sub>) || 4 |
|||
|- |
|||
| 7 || 14 (15<sub>9</sub>) || 6 |
|||
|- |
|||
| 8 || 16 (17<sub>9</sub>) || 8 |
|||
|} |
|||
This means that, for base-9, e.g. both '1' and '5' in doubled positions are equivalent. This has the following consequences for odd N: |
|||
* The algorithm cannot detect all single-digit errors; "17" and "57" both have valid check digits for _sum_ ≡ 0 (mod 9) |
|||
* If it is necessary to have the computed value be in a "doubled" position, it is not be possible to obtain the required modulo sum for all input cases. |
|||
[[User:Stevie-O|Stevie-O]] ([[User talk:Stevie-O|talk]]) 13:48, 30 May 2019 (UTC) |
Revision as of 13:48, 30 May 2019
![]() | Mathematics Start‑class Low‑priority | |||||||||
|
Problems if N is odd
While implementing this algorithm, I noticed an interesting property for odd N:
Consider the case of base-9. For doubled positions, this occurs:
Original digit | Doubled | Reduced |
---|---|---|
0 | 0 (009) | 0 |
1 | 2 (029) | 2 |
2 | 4 (049) | 4 |
3 | 6 (069) | 6 |
4 | 8 (089) | 8 |
5 | 10 (119) | 2 |
6 | 12 (139) | 4 |
7 | 14 (159) | 6 |
8 | 16 (179) | 8 |
This means that, for base-9, e.g. both '1' and '5' in doubled positions are equivalent. This has the following consequences for odd N:
- The algorithm cannot detect all single-digit errors; "17" and "57" both have valid check digits for _sum_ ≡ 0 (mod 9)
- If it is necessary to have the computed value be in a "doubled" position, it is not be possible to obtain the required modulo sum for all input cases.