A257907 After 1, the first differences of A257906 (its d-sequence).
1, 2, 3, -2, 4, -3, 5, -1, 7, -9, 8, -4, 9, -8, 10, -5, 15, -19, 11, -10, 12, -7, 17, -18, 16, -13, 19, -17, 21, -16, 26, -29, 23, -21, 25, -23, 27, -26, 28, -27, 29, -25, 33, -35, 31, -22, 40, -45, 35, -34, 36, -33, 39, -41, 37, -31, 43, -42, 44, -47, 41
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 ((\\)) a257907 n = a257907_list !! (n-1) a257907_list = 1 : f [0] [1] where f xs@(x:_) ds = g [2 - x .. -1] where g [] = h : f ((x + h) : xs) (h : ds) where (h:_) = [z | z <- [1..] \\ ds, x - z `notElem` xs] g (h:hs) | h `notElem` ds && y `notElem` xs = h : 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