Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #14 Jan 29 2018 22:19:40
%S 0,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,19,2,3,4,5,6,7,8,9,28,29,3,4,5,
%T 6,7,8,9,37,38,39,4,5,6,7,8,9,46,47,48,49,5,6,7,8,9,55,56,57,58,59,6,
%U 7,8,9,64,65,66,67,68,69,7,8,9,73,74,75,76,77
%N From right to left in decimal representation of n: replace each maximal set of adjacent digits with their sum, if this sum is less than 10.
%H Reinhard Zumkeller, <a href="/A247796/b247796.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) <= n; a(A248013(n)) = A248013(n); a(A248014(n)) < A248014(n);
%F a(n) = a(a(n)) = a(A004719(n)) = a(n * 10^k).
%e 7654321: 7654[321] -> 7654[3+2+1] -> 76546 -> 76[54]6 -> 76[5+4]6 -> 7696 = a(7654321);
%e 1234567: 123[45]67 -> 123[4+5]67 -> 123967 -> [123]967 -> [1+2+3]967 -> 6967 = a(1234567);
%e 1111111: [1111111] -> [1+1+1+1+1+1+1] -> 7 = a(1111111);
%e a(7777777) = 7777777;
%e 90909: 909[09] -> 909[0+9] -> 9099 -> 9[09]9 -> 9[0+9]9 -> 999 = a(90909);
%e 20202: [20202] -> [2+0+2+0+2] -> 6 = a(20202).
%o (Haskell)
%o a247796 = f 0 where
%o f s 0 = s
%o f s x = if s + d < 10 then f (s + d) x' else (f d x') * 10 + s
%o where (x', d) = divMod x 10
%o (PARI) A247796(n,d=digits(n))={forstep(k=#d,2,-1,if(d[k-1]+d[k]<10, d[k-1]+=d[k]; d=d[^k]));fromdigits(d)} /* or: (about 10% faster) */
%o A247796(n,u=1)={until(n<10*u*=10,my(m=n\u);while(m>9&&sumdigits(m%100)<10, m=vecsum(divrem(m,10));n=m*u+n%u));n} \\ Trying to reduce the number of redefinitions of n yields slower code. _M. F. Hasler_, Jan 29 2018
%Y Cf. A248013, A248014.
%K nonn,base,look
%O 0,3
%A _Reinhard Zumkeller_, Oct 08 2014
%E Edited by _M. F. Hasler_, Jan 29 2018