OFFSET
1,4
EXAMPLE
f(n) = [ 1, 0, 1, 1/2, 1, 1/2, 3/2, 1, ... ]
MATHEMATICA
f[1]=1; f[n_]:=0; f2[n_]:=0; a[n_]:=Block[{q=f2[x]}, If[q!=0, If[x==1, s[n]=1/(n-1-q), s[n]=((n-1-q)*(x))+x], s[n]=1]]; s[1]=1; s[2]=0; x=0; Do[x=a[n]; f2[x]=f[x]; f[x]=n, {n, 3, 100000}]; data=Denominator/@Table[s[n], {n, 1, 100000}];
PROG
(Python)
from fractions import Fraction
from itertools import count, islice
def rfind(lst, item): # find item in list before last index
idx = len(lst) - 2
while lst[idx] != None and lst[idx] != item: idx -= 1
return idx
def agen(): # generator of terms
f = [None, Fraction(1, 1), Fraction(0, 1)]
yield from [1, 1]
for n in count(2):
m = rfind(f, f[n])
if m > 0: fp = Fraction(1, n-m) if f[n] == 1 else f[n] + f[m]*(n-m)
else: fp = Fraction(1, 1)
f.append(fp)
yield fp.denominator
print(list(islice(agen(), 87))) # Michael S. Branicky, Jan 16 2022
(PARI) findm(list, n) = {forstep (m=n-1, 1, -1, if (list[m] == list[n], return(m))); return(0); }
listf(nn) = {my(list = List([1, 0])); for (n=3, nn, my(m = findm(list, n-1)); if (m, if (list[m] == 1, listput(list, 1/(n-1-m)), listput(list, list[n-1]*(n-m))), listput(list, 1); ); ); Vec(list); }
listden(nn) = apply(denominator, listf(nn)); \\ Michel Marcus, Jan 17 2022
CROSSREFS
KEYWORD
nonn,frac
AUTHOR
Jasmine Miller, Jan 05 2022
STATUS
approved