OFFSET
1,2
LINKS
PROG
(Haskell)
import Data.Set (Set, singleton, member, insert)
a187921 n = a187921_list !! (n-1)
a187921_list = r (singleton 0) 1 0 where
r :: Set Integer -> Integer -> Integer -> [Integer]
r s n x | x <= n = n : r (insert (x+n) s) (n+1) (x+n)
| (x-n) `member` s = r (insert (x+n) s) (n+1) (x+n)
| otherwise = r (insert (x-n) s) (n+1) (x-n)
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Mar 17 2011
STATUS
approved