login
a(n) = (a(n-1) * a(n-3) - (-1)^n * a(n-2)^2) / a(n-4) with a(1) = a(3) = a(4) = 1, a(2) = -2.
2

%I #18 Sep 08 2022 08:46:09

%S 1,-2,1,1,-1,1,2,-3,-1,-11,17,46,217,-143,2383,10797,19054,497689,

%T 2407303,-18692747,-184111831,-1592624618,26447728169,396185367129,

%U -372098609569,104735294255689,1574163501502418,-29166210748027547,1549967994300724111

%N a(n) = (a(n-1) * a(n-3) - (-1)^n * a(n-2)^2) / a(n-4) with a(1) = a(3) = a(4) = 1, a(2) = -2.

%H Reinhard Zumkeller, <a href="/A247378/b247378.txt">Table of n, a(n) for n = 1..150</a>

%F 0 = a(n) * a(n+4) - a(n+1) * a(n+3) + (-1)^n * a(n+2)^2 for all n in Z.

%F 0 = a(n) * a(n+9) + a(n+1) * a(n+8) + 9 * a(n+3) * a(n+6) + 9 * a(n+4) * a(n+5) for all n in Z.

%F a(-n) = A247382(n) for all n in Z.

%t RecurrenceTable[{a[0]==1, a[1]==-2, a[2]==1, a[3]==1, a[n]==(a[n-1]a[n-3] - (-1)^n a[n-2]^2)/a[n-4]}, a, {n, 30}] (* _G. C. Greubel_, Aug 05 2018 *)

%o (PARI) {a(n) = if( n<1, (a(n+1) * a(n+3) - (-1)^n * a(n+2)^2) / a(n+4), if( n<5, [1, -2, 1, 1][n], (a(n-1) * a(n-3) - (-1)^n * a(n-2)^2) / a(n-4)))};

%o (PARI) {a(n) = my(A); A = if( n<1, n = 6-n; [-1, 1, 1, -2], [1, -2, 1, 1]); A = concat(A, vector(max(0, n-4))); for(k=5, n, A[k] = (A[k-1] * A[k-3] - (-1)^k * A[k-2]^2) / A[k-4]); A[n]};

%o (Magma) I:=[1,-2,1,1]; [n le 4 select I[n] else (Self(n-1)*Self(n-3)-(-1)^n*Self(n-2)^2)/Self(n-4): n in [1..30]]; // _Vincenzo Librandi_, Sep 16 2014

%o (Haskell)

%o a247378 n = a247378_list !! (n-1)

%o a247378_list = [1, -2, 1, 1] ++ zipWith (flip div) a247378_list

%o (zipWith (+)

%o (zipWith (*) (tail a247378_list) (drop 3 a247378_list))

%o (zipWith (*) (cycle [1, -1]) (map (^ 2) $ drop 2 a247378_list)))

%o -- _Reinhard Zumkeller_, Sep 17 2014

%o (Magma) I:=[1, -2, 1, 1]; [n le 4 select I[n] else ( Self(n-1)*Self(n-3) - (-1)^n*Self(n-2)^2 )/Self(n-4): n in [1..30]]; // _G. C. Greubel_, Aug 05 2018

%o (GAP) a:=[1,-2,1,1];; for n in [5..30] do a[n]:=(a[n-1]*a[n-3]-(-1)^n*a[n-2]^2)/a[n-4]; od; a; # _Muniru A Asiru_, Aug 05 2018

%Y Cf. A247382.

%K sign

%O 1,2

%A _Michael Somos_, Sep 15 2014