cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A231693 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) = denominator of f(n).

Original entry on oeis.org

1, 1, 2, 6, 12, 60, 20, 140, 280, 2520, 2520, 27720, 27720, 360360, 360360, 360360, 720720, 12252240, 4084080, 77597520, 77597520, 11085360, 11085360, 254963280, 84987760, 424938800, 424938800, 11473347600, 80313433200, 2329089562800, 2329089562800, 72201776446800, 144403552893600, 144403552893600
Offset: 0

Views

Author

N. J. A. Sloane, Nov 15 2013

Keywords

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

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.

Crossrefs

Programs

  • 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
    
  • 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
    Denominator[FoldList[# + (-1)^Boole[#*#2 >= 1]/#2 &, Range[0, 35]]] (* Paolo Xausa, Aug 16 2025 *)
  • PARI
    s=0;vector(30,n,denominator(s-=(-1)^(n*s<1)/n)) \\ M. F. Hasler, Nov 15 2013
    
  • Python
    from fractions import Fraction
    A231693 = [(f:=Fraction(0)).denominator] + [(f:=(f + (Fraction(1,i) if Fraction(1,i)>f else -Fraction(1,i)))).denominator for i in range(1, 34)]  # Jwalin Bhatt, Apr 08 2025