A257906 Sequence (a(n)) generated by Rule 3 (in Comments) with a(1) = 0 and d(1) = 1.
0, 2, 5, 3, 7, 4, 9, 8, 15, 6, 14, 10, 19, 11, 21, 16, 31, 12, 23, 13, 25, 18, 35, 17, 33, 20, 39, 22, 43, 27, 53, 24, 47, 26, 51, 28, 55, 29, 57, 30, 59, 34, 67, 32, 63, 41, 81, 36, 71, 37, 73, 40, 79, 38, 75, 44, 87, 45, 89, 42, 83, 46, 91, 48, 95, 49, 97
Offset: 1
Examples
a(1) = 0, d(1) = 1; a(2) = 2, d(2) = 2; a(3) = 5, d(3) = 3; a(4) = 3, d(4) = -2.
Links
- Clark Kimberling (first 1000 terms) & Antti Karttunen, Table of n, a(n) for n = 1..10000
Crossrefs
Programs
-
Haskell
import Data.List ((\\)) a257906 n = a257906_list !! (n-1) a257906_list = 0 : f [0] [1] where f xs@(x:_) ds = g [2 - x .. -1] where g [] = y : f (y:xs) (h:ds) where y = x + h (h:_) = [z | z <- [1..] \\ ds, x - z `notElem` xs] g (h:hs) | h `notElem` ds && y `notElem` xs = y : f (y:xs) (h:ds) | otherwise = g hs where y = x + h -- Reinhard Zumkeller, Jun 03 2015
-
Mathematica
{a, f} = {{0}, {1}}; Do[tmp = {#, # - Last[a]} &[Min[Complement[#, Intersection[a, #]]&[Last[a] + Complement[#, Intersection[f, #]] &[Range[2 - Last[a], -1]]]]]; If[! IntegerQ[tmp[[1]]], tmp = {Last[a] + #, #} &[NestWhile[# + 1 &, 1, ! (! MemberQ[f, #] && ! MemberQ[a, Last[a] - #]) &]]]; AppendTo[a, tmp[[1]]]; AppendTo[f, tmp[[2]]], {120}]; {a, f} (* Peter J. C. Moses, May 14 2015 *)
Comments