cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A247796 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.

Original entry on oeis.org

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, 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, 7, 8, 9, 64, 65, 66, 67, 68, 69, 7, 8, 9, 73, 74, 75, 76, 77
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 08 2014

Keywords

Examples

			7654321: 7654[321] -> 7654[3+2+1] -> 76546 -> 76[54]6 -> 76[5+4]6 -> 7696 = a(7654321);
1234567: 123[45]67 -> 123[4+5]67 -> 123967 -> [123]967 -> [1+2+3]967 -> 6967 = a(1234567);
1111111: [1111111] -> [1+1+1+1+1+1+1] -> 7 = a(1111111);
a(7777777) = 7777777;
90909: 909[09] -> 909[0+9] -> 9099 -> 9[09]9 -> 9[0+9]9 -> 999 = a(90909);
20202: [20202] -> [2+0+2+0+2] -> 6 = a(20202).
		

Crossrefs

Programs

  • Haskell
    a247796 = f 0 where
       f s 0 = s
       f s x = if s + d < 10 then f (s + d) x' else (f d x') * 10 + s
               where (x', d) = divMod x 10
    
  • 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) */
    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

Formula

a(n) <= n; a(A248013(n)) = A248013(n); a(A248014(n)) < A248014(n);
a(n) = a(a(n)) = a(A004719(n)) = a(n * 10^k).

Extensions

Edited by M. F. Hasler, Jan 29 2018