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.

A022518 Describe previous term from the right (method B - initial term is 7).

Original entry on oeis.org

7, 71, 1171, 117112, 21127112, 211271211221, 112212211171211221, 1122122111711322112212, 21112212223112711322112212, 21112212223112712112312311221321
Offset: 0

Views

Author

Keywords

Comments

Method B = 'digit'-indication followed by 'frequency'.

Examples

			The term after 1171 is obtained by saying "1 once, 7 once, 1 twice", which gives 117112.
		

Crossrefs

Programs

  • Haskell
    import Data.List (group, transpose)
    a022518 n = a022518_list !! n
    a022518_list = 7 : f [7] :: [Integer] where
       f xs = (read $ concatMap show ys) : f ys where
              ys = concat $ transpose [map head zss, map length zss]
              zss = reverse $ group xs
    -- Reinhard Zumkeller, Jan 26 2014
  • Mathematica
    split[n_]:=Split[Reverse[IntegerDigits[n]]];
    list1[n_]:=List/@Length/@split[n];riffle1[n_]:=Riffle[split[n],list1[n]];
    tab[n_]:=Table[i,{i,1,2*Length[list1[n]],2}];
    list2[n_]:=Append[riffle1[n][[#]],riffle1[n][[#+1]]]&/@tab[n];
    flat[n_]:=Flatten/@list2[n];riffle2[n_]:=Riffle[First/@flat[n],Last/@flat[n]];
    a[1]=7;a[n_]:=FromDigits[riffle2[a[n-1]]];Array[a,10] (* or *)
    a[1]=7;a[n_]:=FromDigits[Flatten[Replace[Replace[Replace[Split[Reverse[IntegerDigits[
    a[n-1]]]],{x_,y_}-> {x,Length[{x,y}]},{1}],{x_,y_,z_}-> {x,Length[{x,y,z}]},{1}],{x_}-> {x,Length[{x}]},{1}]]];Array[a,10] (* Ivan N. Ianakiev, Oct 07 2016 *)

Extensions

More terms from Erich Friedman
Corrected from 8th term by Patrick De Geest, Jun 15 1999