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.

A088230 a(1)=0; for n>1: a(n)=a(n-1)-n if that number is nonnegative and occurs at most once in the sequence, otherwise a(n)=a(n-1)+n.

Original entry on oeis.org

0, 1, 3, 0, 4, 9, 3, 10, 2, 11, 1, 12, 24, 11, 25, 10, 26, 9, 27, 8, 28, 7, 29, 6, 30, 5, 31, 4, 32, 61, 31, 62, 30, 63, 29, 64, 28, 65, 27, 66, 26, 67, 25, 68, 24, 69, 23, 70, 22, 71, 21, 72, 20, 73, 19, 74, 18, 75, 17, 76, 16, 77, 15, 78, 14, 79, 13, 80, 12, 81, 151, 80, 8, 81
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 03 2003

Keywords

Crossrefs

Programs

  • Haskell
    a088230 n = a088230_list !! (n-1)
    a088230_list = 0 : f [1..] [0] where
       f (x:xs) ys@(y:_)
        | x <= y && (length $ filter (== z) ys) <= 1 = z : f xs (z : ys)
        | otherwise = (x + y) : f xs ((x + y) : ys)  where z = y - x
    -- Reinhard Zumkeller, May 08 2012