OFFSET
1,1
LINKS
Hugo Pfoertner, Table of n, a(n) for n = 1..1191
Sean A. Irvine Java program (github)
Hugo Pfoertner, x values plotted against m.
EXAMPLE
x(0)=1, x(1) = 1/2, x(2) = -1/6 so a(1) = 2 because sgn(x(1)) <> sgn(x(2)).
MAPLE
x := 1;
for n from 1 do
xold := x;
x := x-1/(x+1) ;
if x*xold < 0 then
print(n) ;
end if;
end do: # R. J. Mathar, Jul 23 2023
PROG
(Python)
from itertools import count, islice
def A064690_gen(): # generator of terms
ap, aq, sa = 1, 1, True
for n in count(1):
if (r:=ap+aq) > 0:
bq = aq*r
bp = ap*r-aq**2
else:
bq = -aq*r
bp = aq**2-ap*r
if (sa is not (sb:=bp>0)):
yield n
ap, aq, sa = bp, bq, sb
(PARI) A64690=List(); m64690=0; x64690=1.; A064690(n)={while(n>#A64690, until(sign(x64690)!=sign(x64690-=1/(x64690+1)), m64690++); listput(A64690, m64690)); A64690[n]} \\ Precision must be set to twice the number of desired terms: correct up to a(21) with standard precision \p38, up to a(56) with \p99, up to a(104) with \p199. - M. F. Hasler, Jul 24 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Oct 16 2001
EXTENSIONS
a(13) onward corrected by Sean A. Irvine and Hugo Pfoertner, Jul 23 2023
STATUS
approved