OFFSET
0,2
COMMENTS
Indices of terms in A093017 == 0 mod 10.
A249832(a(n)) = 1; A093017(a(n)) mod 10 = 0; a(n) = 10*n + A093019(n); A093019(n) = a(n) mod 10. - Reinhard Zumkeller, Nov 08 2014
The sequence includes all Canadian Social Insurance Numbers, as well as all modern credit and debit card numbers. - Mathew Englander, Aug 04 2021
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
John Kilgo, DotNetJohn.com, Using the Luhn Algorithm
Webopedia, Luhn formula
Wikipedia, Luhn algorithm
EXAMPLE
PROG
(Haskell)
a093018 n = a093018_list !! n
a093018_list = filter ((== 1) . a249832) [0..]
-- Reinhard Zumkeller, Nov 08 2014
(Python)
def a(n):
s = str(n)
r = s[::-1]
x = sum(int(d) for d in r[1::2])
x += sum(q if (q:=2*int(d)) < 10 else q-9 for d in r[::2])
x = x%10
c = str((10 - x) if x > 0 else 0)
return int(s+c)
print([a(n) for n in range(54)]) # Michael S. Branicky, Jul 23 2024
CROSSREFS
KEYWORD
easy,nonn,base
AUTHOR
Ray Chandler, Apr 03 2004
EXTENSIONS
Original name end comment interchanged by Reinhard Zumkeller, Nov 08 2014
STATUS
approved