login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
3
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,3
PROG
(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
CROSSREFS
Sequence in context: A021332 A377371 A008344 * A181482 A330420 A072329
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Nov 03 2003
STATUS
approved