Luhn test of credit card numbers: Difference between revisions
→{{header|RPL}}: corrected major bug
m (→{{header|RPL}}: typo) |
(→{{header|RPL}}: corrected major bug) |
||
Line 5,698:
=={{header|RPL}}==
Card numbers shall be entered as strings to avoid any rounding error when testing long ones.
{{works with|
{| class="wikitable"
! RPL code
Line 5,704:
|-
|
« 0
card SIZE 1
'''IF'''
DUP +
-1 '''STEP'''
≫ ≫ '<span style="color:blue">LUHN?</span>' STO▼
10 MOD NOT
|
<span style="color:blue">LUHN?</span> ''( "card_number" -- boolean ) ''
sum = 0
loop for j=n to 1
digit = card[j]
if even digit
multiply it by 2 and add digits
sum += digit ; reverse parity flag
return not(sum mod 10)
|}
{{out}}
<pre>
|