login
A079053
Recamán Fibonacci variation: a(1)=1; a(2)=2; for n > 2, a(n) = a(n-1)+a(n-2)-F(n) if that number is positive and not already in the sequence, otherwise a(n) = a(n-1)+a(n-2)+F(n) where F(n) denotes the n-th Fibonacci number.
8
1, 2, 5, 4, 14, 10, 11, 42, 19, 6, 114, 264, 145, 32, 787, 1806, 996, 218, 5395, 12378, 6827, 1494, 36978, 84840, 46793, 10240, 253451, 581502, 320724, 70186, 1737179, 3985674, 2198275, 481062, 11906802, 27318216, 15067201, 3297248, 81610435
OFFSET
1,2
COMMENTS
Starting with other initial values a(1)=x a(2)=y gives the same kind of recurrence relations.
LINKS
FORMULA
For n>2, if n==0 or 2 (mod 4) a(n)=2*a(n-1)-a(n-2)-a(n-4); if n==1 or 3 (mod 4) a(n)=a(n-2)+2*a(n-3)+a(n-4) lim n ->infinity a(4n)/a(4n-1)=2.29433696806047607330083539....; lim n ->infinity a(4n-1)/a(4n-2)=24.7510757456062014116731647..; lim n ->infinity a(4n-2)/a(4n-3)=0.218836132868832627648170038...; lim n ->infinity a(4n-3)/a(4n-4)=0.551544105222898180785441647...
Empirical g.f.: x*(26*x^10+68*x^8+6*x^7-4*x^6+16*x^5-12*x^4-5*x^2-x-1) / ((x^2+x-1)*(x^4+3*x^2+1)). - Colin Barker, Jun 26 2013
EXAMPLE
a(10)=6 because a(9)+a(8)-F(10)=19+42-55=6 and 6 is not already in the sequence. a(11)=42 because a(10)+a(9)-F(11)=6+19-89 < 0 then a(11)=6+19+89=114.
MATHEMATICA
a[1] = 1; a[2] = 2; a[n_] := a[n] = (an = a[n-1] + a[n-2] - Fibonacci[n]; If[an > 0 && ! MemberQ[Array[a, n-1], an], an, a[n-1] + a[n-2] + Fibonacci[n]]); Table[a[n], {n, 1, 39}] (* Jean-François Alcover, Jun 18 2012 *)
PROG
(PARI) m=200; a=vector(m); a[1]=1; a[2]=2; for(n=3, m, a[n]=if(n<0, 0, if(abs(sign(a[n-1]+a[n-2]-fibonacci(n))-1)+setsearch(Set(vector(n-1, i, a[i])), a[n-1]+a[n-2]-fibonacci(n)), a[n-1]+a[n-2]+fibonacci(n), a[n-1]+a[n-2]-fibonacci(n)))); a - corrected by Colin Barker, Jun 26 2013
(Haskell)
import Data.Set (Set, fromList, notMember, insert)
a079053 n = a079053_list !! (n-1)
a079053_list = 1 : 2 : r (fromList [1, 2]) 1 1 1 2 where
r :: Set Integer -> Integer -> Integer -> Integer -> Integer -> [Integer]
r s i j x y = if v > 0 && v `notMember` s
then v : r (insert v s) j fib y v
else w : r (insert w s) j fib y w where
fib = i + j
v = x + y - fib
w = x + y + fib
for_bFile = take 1000 a079053_list -- Reinhard Zumkeller, Mar 14 2011
CROSSREFS
Cf. A005132.
Sequence in context: A102468 A252668 A225046 * A224272 A189942 A251554
KEYWORD
nice,nonn
AUTHOR
Benoit Cloitre, Feb 02 2003
STATUS
approved