Anonymous user
Luhn test of credit card numbers: Difference between revisions
Luhn test of credit card numbers (view source)
Revision as of 05:22, 15 November 2011
, 12 years ago→{{header|Python}}: Link divmof to its documentation
(→{{header|Python}}: Link divmof to its documentation) |
|||
Line 1,490:
=={{header|Python}}==
The [http://docs.python.org/py3k/library/functions.html#divmod divmod] in the function below conveniently splits a number into its two digits ready for summing:
<lang python>>>> def luhn(n):
r = [int(ch) for ch in str(n)][::-1]
|