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

This page as a plain text file.
%I A022518 #21 Oct 14 2016 08:12:15
%S A022518 7,71,1171,117112,21127112,211271211221,112212211171211221,
%T A022518 1122122111711322112212,21112212223112711322112212,
%U A022518 21112212223112712112312311221321
%N A022518 Describe previous term from the right (method B - initial term is 7).
%C A022518 Method B = 'digit'-indication followed by 'frequency'.
%H A022518 Reinhard Zumkeller, <a href="/A022518/b022518.txt">Table of n, a(n) for n = 0..21</a>
%e A022518 The term after 1171 is obtained by saying "1 once, 7 once, 1 twice", which gives 117112.
%t A022518 split[n_]:=Split[Reverse[IntegerDigits[n]]];
%t A022518 list1[n_]:=List/@Length/@split[n];riffle1[n_]:=Riffle[split[n],list1[n]];
%t A022518 tab[n_]:=Table[i,{i,1,2*Length[list1[n]],2}];
%t A022518 list2[n_]:=Append[riffle1[n][[#]],riffle1[n][[#+1]]]&/@tab[n];
%t A022518 flat[n_]:=Flatten/@list2[n];riffle2[n_]:=Riffle[First/@flat[n],Last/@flat[n]];
%t A022518 a[1]=7;a[n_]:=FromDigits[riffle2[a[n-1]]];Array[a,10] (* or *)
%t A022518 a[1]=7;a[n_]:=FromDigits[Flatten[Replace[Replace[Replace[Split[Reverse[IntegerDigits[
%t A022518 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 *)
%o A022518 (Haskell)
%o A022518 import Data.List (group, transpose)
%o A022518 a022518 n = a022518_list !! n
%o A022518 a022518_list = 7 : f [7] :: [Integer] where
%o A022518    f xs = (read $ concatMap show ys) : f ys where
%o A022518           ys = concat $ transpose [map head zss, map length zss]
%o A022518           zss = reverse $ group xs
%o A022518 -- _Reinhard Zumkeller_, Jan 26 2014
%Y A022518 Cf. A022481, A022488, A022514, A022515, A022516, A022517, A022519, A022520.
%K A022518 nonn,base,easy,nice
%O A022518 0,1
%A A022518 _N. J. A. Sloane_
%E A022518 More terms from _Erich Friedman_
%E A022518 Corrected from 8th term by _Patrick De Geest_, Jun 15 1999