Damm algorithm: Difference between revisions
Content added Content deleted
(→static table: simplified and optimized the code.) |
|||
Line 1,214: | Line 1,214: | ||
@.0= 0317598642; @.1= 7092154863; @.2= 4206871359; @.3= 1750983426; @.4= 6123045978 |
@.0= 0317598642; @.1= 7092154863; @.2= 4206871359; @.3= 1750983426; @.4= 6123045978 |
||
@.5= 3674209581; @.6= 5869720134; @.7= 8945362017; @.8= 9438617205; @.9= 2581436790 |
@.5= 3674209581; @.6= 5869720134; @.7= 8945362017; @.8= 9438617205; @.9= 2581436790 |
||
call Damm 5724 5727 112946 112940 |
call Damm 5724, 5727, 112946, 112940 /*invoke Damm's algorithm for some #'s.*/ |
||
exit |
exit 0 /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
Damm: |
Damm: do j=1 for arg(); x= arg(j); $= 0; z= right(x, 1) |
||
do p=1 for length(x); g=$; $= substr(@.$, 1 + substr(x, p, 1), 1) |
|||
end /*p*/ |
|||
do p=1 for L; g=$; $= substr(@.$, 1 + substr(x, p, 1), 1) |
|||
if $==0 then say ' valid checksum digit ' z " for " x |
|||
else say ' invalid checksum digit ' z " for " x ' (should be' g")" |
|||
end /*j*/; return</lang> |
|||
end /*j*/; return</lang> |
|||
{{out|output|text= when using the (internal) default inputs:}} |
{{out|output|text= when using the (internal) default inputs:}} |
||
<pre> |
<pre> |