Luhn test of credit card numbers: Difference between revisions
Content added Content deleted
m (→{{header|Go}}: language change. rune type) |
|||
Line 998: | Line 998: | ||
print(luhn'1234567812345678') |
print(luhn'1234567812345678') |
||
print(luhn'1234567812345670')</lang> |
print(luhn'1234567812345670')</lang> |
||
=={{header|Mathematica}}== |
|||
<lang Mathematica>LuhnQ[nb_] := (Mod[Total[(2*ToExpression[#[[2;;All;;2]]]) /. {z_?(Function[v, v>9]) -> z-9}] |
|||
+ Total[ToExpression[#[[1;;All;;2]]]], 10] == 0)& [Characters[StringReverse[ToString[nb]]] ] |
|||
LuhnQ /@ {49927398716, 49927398717, 1234567812345678, 1234567812345670} |
|||
->{True, False, False, True}</lang> |
|||
=={{header|MATLAB}}== |
=={{header|MATLAB}}== |