Luhn test of credit card numbers: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Link divmof to its documentation)
Line 1,490: Line 1,490:


=={{header|Python}}==
=={{header|Python}}==
The divmod in the function below conveniently splits a number into its two digits ready for summing:
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):
<lang python>>>> def luhn(n):
r = [int(ch) for ch in str(n)][::-1]
r = [int(ch) for ch in str(n)][::-1]