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.
%I A116939 #12 Dec 07 2016 10:36:12 %S A116939 0,1,2,1,2,3,2,3,4,3,4,3,4,5,4,5,4,5,6,5,6,5,6,5,6,7,6,7,6,7,6,7,8,7, %T A116939 8,7,8,7,8,7,8,9,8,9,8,9,8,9,8,9,10,9,10,9,10,9,10,9,10,9,10,11,10,11, %U A116939 10,11,10,11,10,11,10,11,12,11,12,11,12,11,12,11,12,11,12,11,12,13,12,13 %N A116939 Lexicographically earliest sequence such that each i occurs exactly i+1 times and succeeding terms differ exactly by -1 or +1. %C A116939 Permutation of A003056: a(n)=A003056(A116942(n)), a(A116941(n))=A003056(n); %C A116939 for n>1: let x = number of occurrences of the most frequent term so far, a(n) = if x=a(n-1) then x+1 else x, a(1) = 1; %C A116939 a(A000982(n))=a(A116940(n))=n, a(m)<n for m < A000982(n) and a(m)>n for m>A000982(n). %H A116939 Reinhard Zumkeller, <a href="/A116939/b116939.txt">Table of n, a(n) for n = 0..10000</a> %t A116939 a = {0}; Do[AppendTo[a, If[Count[a, # - 1] > # - 1, # + 1, # - 1]] &@ a[[n]], {n, 87}]; a (* _Michael De Vlieger_, Dec 07 2016 *) %o A116939 (Haskell) %o A116939 a116939 n = a116939_list !! n %o A116939 a116939_list = 0 : f [0] where %o A116939 f xs@(x : _) = ys ++ f ys where %o A116939 ys = if odd x then (x + 1 : x : map (+ 1) xs) else map (+ 1) xs %o A116939 -- _Reinhard Zumkeller_, Jun 28 2013 %K A116939 nonn %O A116939 0,3 %A A116939 _Reinhard Zumkeller_, Feb 27 2006