login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A070897 Number of ways of pairing numbers 1 to n with numbers n+1 to 2n such that each pair sums to a prime. 7

%I #31 Sep 21 2023 14:16:04

%S 1,1,1,1,2,4,8,36,40,49,126,121,440,2809,11395,32761,132183,881721,

%T 3015500,19642624,106493895,249987721,1257922092,4609187881,

%U 29262161844,189192811369,1068996265025,7388339422500,67416357342087,465724670229025,1979950199225010

%N Number of ways of pairing numbers 1 to n with numbers n+1 to 2n such that each pair sums to a prime.

%H Martin Fuller, <a href="/A070897/b070897.txt">Table of n, a(n) for n = 1..70</a>

%F a(n) = permanent(m), where the n X n matrix m is defined by m(i,j) = 1 or 0, depending on whether i+j+n is prime or composite, respectively. - _T. D. Noe_, Feb 10 2007

%F a(n) = A071058(n) * A071059(n).

%e a(5)=2 because there are two ways: 1+10, 2+9, 3+8, 4+7, 6+5 and 1+6, 2+9, 3+10, 4+7, 5+8.

%t <<Combinatorica`; listQpart2[ n_ ] := {n-#, #}&/@Range[ Floor[ (n-1)/2 ] ]; Noe[ n_Integer ] := Module[ {it, permoid, po}, it=Union@Flatten[ Cases[ listQpart2[ # ], q_/; Max[ q ]<=2*n&&Max[ q ]>n ]& /@Select[ Range[ n+2, 3*n ], PrimeQ ], 1 ]; po=Position[ it, # ]&/@Range[ n ]; permoid=(Extract[ it, # ]-n)& /@(po /. {i_Integer, j_}->{i, 1} ); Length@Backtrack[ permoid, UnsameQ@@#&, Length[ # ]===n&, All ] ]; Noe/@Range[ 2, 16 ] (* from _Wouter Meeussen_ *)

%t a[n_] := Permanent[Table[If[PrimeQ[i+j+n], 1, 0], {i, n}, {j, n}]]; Table[ an = a[n]; Print["a(", n, ") = ", an]; an, {n, 1, 16}] (* _Jean-François Alcover_, Feb 26 2016 *)

%o (Haskell)

%o import Data.List (permutations)

%o a070897 n = length $ filter (all ((== 1) . a010051))

%o $ map (zipWith (+) [1..n]) (permutations [n+1..2*n])

%o -- _Reinhard Zumkeller_, Mar 19 2011, Apr 16 2011 (fixed)

%o (PARI) a(n)=my(a071058=matpermanent(matrix((n+1)\2,(n+1)\2,i,j,isprime((i+j-2)*2+n+3-(n%2))))); if(n%2==0, a071058^2, a071058*matpermanent(matrix(n\2,n\2,i,j,isprime((i+j-2)*2+n+3+(n%2))))); \\ _Martin Fuller_, Sep 21 2023

%Y Cf. A000341, A071058, A071059, A073364.

%K nice,nonn

%O 1,5

%A _T. D. Noe_, May 23 2002

%E More terms from _Don Reble_, May 26 2002

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 29 02:23 EDT 2024. Contains 371264 sequences. (Running on oeis4.)