[go: up one dir, main page]

login
a(n) = a(n-1)*a(n-2) + a(n-3).
(Formerly M0859 N0328)
1

%I M0859 N0328 #33 Sep 08 2022 08:44:28

%S 1,1,0,1,1,1,2,3,7,23,164,3779,619779,2342145005,1451612289057674,

%T 3399886472013047316638149,4935316984175079105557291745555191750431,

%U 16779517449593082173916263081219908459297087421776218065830849893

%N a(n) = a(n-1)*a(n-2) + a(n-3).

%C The next term, a(18), has 104 digits. - _Harvey P. Dale_, Dec 12 2018

%D N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H Reinhard Zumkeller, <a href="/A001064/b001064.txt">Table of n, a(n) for n = 0..22</a>

%p a:= proc (n) option remember;

%p if n < 2 then 1

%p elif n=2 then 0

%p else a(n-1)*a(n-2) + a(n-3)

%p end if

%p end proc;

%p seq(a(n), n = 0..20); # _G. C. Greubel_, Sep 19 2019

%t t = {1, 1, 0}; Do[AppendTo[t, t[[-1]] * t[[-2]] + t[[-3]]], {n, 3, 20}]; t (* _T. D. Noe_, Jun 25 2012 *)

%t RecurrenceTable[{a[0]==a[1]==1,a[2]==0,a[n]==a[n-1]*a[n-2]+a[n-3]},a,{n,18}] (* _Harvey P. Dale_, Dec 12 2018 *)

%o (Haskell)

%o a001064 n = a001064_list !! n

%o a001064_list = 1 : 1 : 0 : zipWith (+) a001064_list

%o (tail $ zipWith (*) a001064_list (tail a001064_list))

%o -- _Reinhard Zumkeller_, Dec 30 2011

%o (PARI) m=20; v=concat([1,1,0], vector(m-3)); for(n=4, m, v[n]=v[n-1]*v[n-2] +v[n-3]); v \\ _G. C. Greubel_, Sep 19 2019

%o (Magma) I:=[1,1,0]; [n le 3 select I[n] else Self(n-1)*Self(n-2) + Self(n-3): n in [1..20]]; // _G. C. Greubel_, Sep 19 2019

%o (Sage)

%o def a(n):

%o if (n==0 or n==1): return 1

%o elif (n==2): return 0

%o else: return a(n-1)*a(n-2) + a(n-3)

%o [a(n) for n in (0..20)] # _G. C. Greubel_, Sep 19 2019

%o (GAP) a:=[1,1,0];; for n in [4..20] do a[n]:=a[n-1]*a[n-2]+a[n-3]; od; a; # _G. C. Greubel_, Sep 19 2019

%K nonn,easy

%O 0,7

%A _N. J. A. Sloane_, _R. K. Guy_