login
a(n+1) = a(n)-a(1)a(2)...a(n-1), if n>0. a(0)=1, a(1)=2.
4

%I #29 Sep 08 2022 08:44:32

%S 1,2,1,-1,-3,-1,-7,-1,-43,-1,-1807,-1,-3263443,-1,-10650056950807,-1,

%T -113423713055421844361000443,-1,

%U -12864938683278671740537145998360961546653259485195807,-1

%N a(n+1) = a(n)-a(1)a(2)...a(n-1), if n>0. a(0)=1, a(1)=2.

%C a(n) = a(n-1)-a(n-2)^2+a(n-1)*a(n-2), if n>2. - _Michael Somos_, Mar 19 2004

%C Consider the mapping f(a/b) = (a - b)/(ab). Taking a = 2 b = 1 to start with and carrying out this mapping repeatedly on each new (reduced) rational number gives the following sequence 2/1,1/2,-1/2,-3/-2,-1/6,... Sequence contains the numerators. - _Amarnath Murthy_, Mar 24 2003

%C An infinite coprime sequence defined by recursion. - _Michael Somos_, Mar 19 2004

%H Seiichi Manyama, <a href="/A003687/b003687.txt">Table of n, a(n) for n = 0..27</a>

%t {1}~Join~NestList[{(#1 - #2), #1 #2} & @@ # &, {2, 1}, 17] [[All, 1]] (* _Michael De Vlieger_, Sep 04 2016 *)

%o (PARI) a(n)=local(an); if(n<1,(n==0),an=vector(max(2,n)); an[1]=2; an[2]=1; for(k=3,n,an[k]=an[k-1]-an[k-2]^2+an[k-1]*an[k-2]); an[n])

%o (Sage)

%o def A003687():

%o x, y = 2, 1

%o yield y

%o while true:

%o yield x

%o x, y = x - y, x * y

%o a = A003687(); print([next(a) for i in range(20)]) # _Peter Luschny_, Dec 17 2015

%o (Magma) I:=[1,2,1]; [n le 3 select I[n] else Self(n-1)-Self(n-2)^2+Self(n-1)*Self(n-2): n in [1..30]]; // _Vincenzo Librandi_, Dec 17 2015

%Y Cf. A081478.

%Y For n>1, a(2n-1) = -1, a(2n) = -A007018(n-1) - 1.

%K sign,easy

%O 0,2

%A _N. J. A. Sloane_