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

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

%S 0,1,1,1,1,2,1,5,9,17,4,65,121,277,841,2746,441,28561,93025,312001,

%T 583696,5309441,14145121,116815697,719795241,4487760170,433763929,

%U 175081030037,1091329140889,6935920173025,53828252727076,610296440614897,1223724862004841

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

%C This is similar to Somos-4 (A006720) except for the alternating coefficient of a(n-2)^2.

%H Reinhard Zumkeller, <a href="/A247368/b247368.txt">Table of n, a(n) for n = 0..250</a>

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

%F a(n) = a(-n), a(2*n) = A178384(n)^2 for all n in Z.

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

%o (PARI) {a(n) = n=abs(n); if( n<5, n>0, (a(n-1) * a(n-3) - (-1)^n * a(n-2)^2) / a(n-4))};

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

%o (Haskell)

%o a247368 n = a247368_list !! n

%o a247368_list = 0 : xs where

%o xs = [1, 1, 1, 1] ++ zipWith (flip div) xs (zipWith (+)

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

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

%o -- _Reinhard Zumkeller_, Sep 15 2014

%o (Magma) I:=[1, 1, 1, 1]; [0] cat [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

%Y Cf. A178384.

%K nonn

%O 0,6

%A _Michael Somos_, Sep 14 2014