

A093017


Luhn algorithm doubleandadd sum of digits of n.


16



0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 7, 8, 9, 10, 11, 12, 13
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,3


COMMENTS

Starting on the right, sum digits after doubling alternating digits beginning with the second. If doubled digit >9, reduce by 9 (sum of digits).
First differences are b(n) defined for n>0 as follows. Take the prime factorization of n and let x be the number of 2's, y be the number of 5's, and z be min(x,y). If z is even, b(n) = 1  9*z. If z is odd and y=z, b(n) = 2  9*z. If z is odd and y>z, b(n) = 7  9*z. Now a(n) = a(n1) + b(n).  Mathew Englander, Aug 04 2021


LINKS



FORMULA

a(0)=0; for n not divisible by 10, a(n)=1+a(n1); for n divisible by 10 but not 50, a(n)=2+a(n10); for n divisible by 50 but not 100, a(n)=1+a(n50); for n divisible by 100, a(n)=a(n/100).  Mathew Englander, Aug 04 2021


EXAMPLE

a(18) = 2*1 + 8 = 10.
a(59) = (1+0) + 9 = 10 (1 and 0 are the digits in 10 = 2*5).


PROG

(Haskell)
a093017 n = if n == 0 then 0 else a093017 n' + a007953 (2 * t) + d
where (n', td) = divMod n 100; (t, d) = divMod td 10


CROSSREFS



KEYWORD

easy,nonn,base


AUTHOR



STATUS

approved



