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 A226247 #30 Apr 27 2025 09:08:01 %S A226247 1,1,1,1,1,2,1,3,2,1,4,3,2,1,1,5,4,3,2,2,3,1,6,5,4,3,3,5,2,5,3,1,7,6, %T A226247 5,4,4,7,3,8,5,2,7,5,3,1,1,8,7,6,5,5,9,4,11,7,3,11,8,5,2,2,9,7,5,3,3, %U A226247 4,1,9,8,7,6,6,11,5,14,9,4,15,11,7,3,3 %N A226247 Let S be the set of numbers defined by these rules: 0 is in S; if x is in S, then x+1 is in S, and if nonzero x is in S, then -1/x are in S. (See Comments.) %C A226247 Let S be the set of numbers defined by these rules: 0 is in S; if x is in S, then x+1 is in S, and if nonzero x is in S, then -1/x are in S. Then S is the set of all rational numbers, produced in generations as follows: %C A226247 g(1) = (0), g(2) = (1), g(3) = (2, -1), g(4) = (3, -1/2), g(5) = (4, -1/3, 1/2), ... For n > 2, once g(n-1) = (c(1), ..., c(z)) is defined, g(n) is formed from the vector (c(1)+1, -1/c(1), c(2)+1, -1/c(2), ..., c(z)+1, -1/c(z)) by deleting previously generated elements. %C A226247 Let S'' denote the sequence formed by concatenating the generations. %C A226247 A226247: Denominators of terms of S'' %C A226247 A226248: Numerators of terms of S'' %C A226247 A226249: Positions of nonnegative numbers in S'' %C A226247 A226250: Positions of positive numbers in S'' %C A226247 A closely related sequence S' (for which the rules of generation are shorter but the resulting sequence is slightly less natural) is discussed at A226130. For both S' and S'', the number of numbers in g(n) is given by A097333. %H A226247 Clark Kimberling, <a href="/A226247/b226247.txt">Table of n, a(n) for n = 1..1000</a> %H A226247 Peter Kagey, <a href="/A226247/a226247.pdf">Illustration of first seven generations.</a> %e A226247 The denominators and numerators are read from S'': %e A226247 0/1, 1/1, 2/1, -1/1, 3, -1/2, 4/1, -1/3, 1/2, 5, -1/4, 2/3, 3/2, -2, ... %e A226247 Table begins: %e A226247 n | %e A226247 --+----------------------------------------------- %e A226247 1 | 1; %e A226247 2 | 1; %e A226247 3 | 1, 1; %e A226247 4 | 1, 2; %e A226247 5 | 1, 3, 2; %e A226247 6 | 1, 4, 3, 2, 1; %e A226247 7 | 1, 5, 4, 3, 2, 2, 3; %e A226247 8 | 1, 6, 5, 4, 3, 3, 5, 2, 5, 3; %e A226247 9 | 1, 7, 6, 5, 4, 4, 7, 3, 8, 5, 2, 7, 5, 3, 1; %t A226247 z = 12; g[1] := {0}; g[2] := {1}; g[n_] := g[n] = DeleteCases[Flatten[Transpose[{# + 1, -1/#}]] &[g[n - 1]], Apply[Alternatives, Flatten[Map[g, Range[n - 1]]]]]; f = Flatten[Map[g, Range[z]]]; Take[Denominator[f], 100] (*A226247*) %t A226247 t = Take[Numerator[f], 100] (*A226248*) %t A226247 s[n_] := If[t[[n]] > 0, 1, 0]; u = Table[s[n], {n, 1, Length[t]}] %t A226247 Flatten[Position[u, 1]] (*A226249*) %t A226247 p = Flatten[Position[u, 0]] (*A226250*) (* _Peter J. C. Moses_, May 30 2013 *) %o A226247 (Python) %o A226247 from fractions import Fraction %o A226247 from itertools import count, islice %o A226247 def agen(): %o A226247 rats = [Fraction(0, 1)] %o A226247 seen = {Fraction(0, 1)} %o A226247 for n in count(1): %o A226247 yield from [r.denominator for r in rats] %o A226247 newrats = [] %o A226247 for r in rats: %o A226247 f = 1+r %o A226247 if f not in seen: %o A226247 newrats.append(1+r) %o A226247 seen.add(f) %o A226247 if r != 0: %o A226247 g = -1/r %o A226247 if g not in seen: %o A226247 newrats.append(-1/r) %o A226247 seen.add(g) %o A226247 rats = newrats %o A226247 print(list(islice(agen(), 84))) # _Michael S. Branicky_, Jan 17 2022 %Y A226247 Cf. A226080 (rabbit ordering of positive rationals), A226130. %Y A226247 Cf. A226248, A226249, A226250. %K A226247 nonn,easy,tabf %O A226247 1,6 %A A226247 _Clark Kimberling_, Jun 01 2013