Welcome, guest | Sign In | My Account | Store | Cart
def luhn(n):
    r = [int(ch) for ch in str(n)][::-1]
    return (sum(r[0::2]) + sum(sum(divmod(d*2,10)) for d in r[1::2])) % 10 == 0

History

  • revision 2 (14 years ago)
  • previous revisions are not available