OFFSET
1,6
COMMENTS
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:
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. Let S'' denote the sequence formed by concatenating the generations.
A226247: Denominators of terms of S''
A226248: Numerators of terms of S''
A226249: Positions of nonnegative numbers in S''
A226250: Positions of positive numbers in S''
LINKS
Clark Kimberling, Table of n, a(n) for n = 1..1000
EXAMPLE
The denominators and numerators are read from S'':
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, ...
Table begins:
n |
--+-----------------------------------------------
1 | 1;
2 | 1, 1;
3 | 1, 2;
4 | 1, 3, 2;
5 | 1, 4, 3, 2, 1;
6 | 1, 5, 4, 3, 2, 2, 3;
7 | 1, 6, 5, 4, 3, 3, 5, 2, 5, 3;
8 | 1, 7, 6, 5, 4, 4, 7, 3, 8, 5, 2, 7, 5, 3, 1;
MATHEMATICA
Clear[g]; 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 = Take[Numerator[f], 100] (*A226248*)
s[n_] := If[t[[n]] > 0, 1, 0]; u = Table[s[n], {n, 1, Length[t]}]
Flatten[Position[u, 1]] (*A226249*)
p = Flatten[Position[u, 0]] (*A226250*) (* Peter J. C. Moses, May 30 2013 *)
PROG
(Python)
from fractions import Fraction
from itertools import count, islice
def agen():
rats = [Fraction(0, 1)]
seen = {Fraction(0, 1)}
for n in count(1):
yield from [r.denominator for r in rats]
newrats = []
for r in rats:
f = 1+r
if f not in seen:
newrats.append(1+r)
seen.add(f)
if r != 0:
g = -1/r
if g not in seen:
newrats.append(-1/r)
seen.add(g)
rats = newrats
print(list(islice(agen(), 84))) # Michael S. Branicky, Jan 17 2022
CROSSREFS
KEYWORD
nonn,easy,tabf
AUTHOR
Clark Kimberling, Jun 01 2013
STATUS
approved