A231692 Define a sequence of rationals by f(0)=0, thereafter f(n)=f(n-1)-1/n if that is >= 0, otherwise f(n)=f(n-1)+1/n; a(n) = numerator of f(n).
0, 1, 1, 1, 5, 13, 1, 27, 19, 451, 199, 4709, 2399, 3467, 29207, 5183, 55411, 221267, 300649, 1628251, 5508127, 259001, 762881, 6460903, 5694791, 11476403, 27820203, 326206681, 5151783667, 69088293143, 146724611903, 2219373406193, 8951357840311, 4575492601111, 328329280711, 4454145077671
Offset: 0
Examples
0, 1, 1/2, 1/6, 5/12, 13/60, 1/20, 27/140, 19/280, 451/2520, 199/2520, 4709/27720, ...
References
- David Wilson, Posting to Sequence Fans Mailing List, Nov 14 2013.
Links
- David W. Wilson and Reinhard Zumkeller, Table of n, a(n) for n = 0..1000
Programs
-
Haskell
a231692_list = map numerator $ 0 : wilson 1 0 where wilson x y = y' : wilson (x + 1) y' where y' = y + (if y < 1 % x then 1 else -1) % x -- Reinhard Zumkeller, Nov 16 2013
-
Maple
f:=proc(n) option remember; if n=0 then 0 elif f(n-1) >= 1/n then f(n-1)-1/n else f(n-1)+1/n; fi; end;
-
Mathematica
Numerator[FoldList[# + (-1)^Boole[#*#2 >= 1]/#2 &, Range[0, 35]]] (* Paolo Xausa, Aug 16 2025 *)
-
PARI
s=0;vector(30,n,numerator(s-=(-1)^(n*s<1)/n)) \\ - M. F. Hasler, Nov 15 2013
Comments