OFFSET
0,3
COMMENTS
See Comments in A231692, which is the sequence of numerators of {f(n)}.
Note that this sequence is not monotonic.
Differs from A002805 starting at a(20)=77597520: A002805(20)=15519504. See also A203811 for a very similar idea. - M. F. Hasler, Nov 15 2013
REFERENCES
David Wilson, Posting to Sequence Fans Mailing List, Nov 14 2013.
LINKS
David W. Wilson, Table of n, a(n) for n = 0..200
EXAMPLE
0, 1, 1/2, 1/6, 5/12, 13/60, 1/20, 27/140, 19/280, 451/2520, 199/2520, 4709/27720, ...
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;
PROG
(PARI) s=0; vector(30, n, denominator(s-=(-1)^(n*s<1)/n)) \\ - M. F. Hasler, Nov 15 2013
(Haskell)
a231693 n = a231693_list !! n
a231693_list = map denominator $ 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
CROSSREFS
KEYWORD
nonn,frac
AUTHOR
N. J. A. Sloane, Nov 15 2013
STATUS
approved