OFFSET
0,2
COMMENTS
a(n) = a(n-1)-a(n-2)^2+a(n-1)*a(n-2), if n>2. - Michael Somos, Mar 19 2004
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
An infinite coprime sequence defined by recursion. - Michael Somos, Mar 19 2004
LINKS
Seiichi Manyama, Table of n, a(n) for n = 0..27
MATHEMATICA
{1}~Join~NestList[{(#1 - #2), #1 #2} & @@ # &, {2, 1}, 17] [[All, 1]] (* Michael De Vlieger, Sep 04 2016 *)
PROG
(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])
(Sage)
def A003687():
x, y = 2, 1
yield y
while true:
yield x
x, y = x - y, x * y
a = A003687(); print([next(a) for i in range(20)]) # Peter Luschny, Dec 17 2015
(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
CROSSREFS
KEYWORD
sign,easy
AUTHOR
STATUS
approved