cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

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

Original entry on oeis.org

1, 1, 1, 1, 2, 4, 8, 36, 40, 49, 126, 121, 440, 2809, 11395, 32761, 132183, 881721, 3015500, 19642624, 106493895, 249987721, 1257922092, 4609187881, 29262161844, 189192811369, 1068996265025, 7388339422500, 67416357342087, 465724670229025, 1979950199225010
Offset: 1

Views

Author

T. D. Noe, May 23 2002

Keywords

Examples

			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.
		

Crossrefs

Programs

  • Haskell
    import Data.List (permutations)
    a070897 n = length $ filter (all ((== 1) . a010051))
                         $ map (zipWith (+) [1..n]) (permutations [n+1..2*n])
    -- Reinhard Zumkeller, Mar 19 2011, Apr 16 2011 (fixed)
    
  • Mathematica
    <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 *)
    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 *)
  • 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

Formula

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
a(n) = A071058(n) * A071059(n).

Extensions

More terms from Don Reble, May 26 2002

A071058 Number of ways of pairing odd numbers in the range 1 to n with even numbers in the range n+1 to 2n such that each pair sums to a prime.

Original entry on oeis.org

1, 1, 1, 1, 2, 2, 4, 6, 10, 7, 21, 11, 40, 53, 215, 181, 773, 939, 3260, 4432, 23431, 15811, 80724, 67891, 429108, 434963, 2748239, 2718150, 21654009, 21580655, 107459138, 92370364, 638616984, 564878656, 5055810584, 4545704064, 35787453599, 36878092180
Offset: 1

Views

Author

T. D. Noe, May 25 2002

Keywords

Examples

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

Crossrefs

The product of this sequence and A071059 gives A070897.

Programs

  • Mathematica
    a[n_] := a[n] = Module[{s1, s2, s3, s4, i, ik, km},
    s1 = Select[Flatten[Outer[List, Range[1, n, 2], Range[2n, n+1, -2]], 1],
       PrimeQ[Total[#]]&];
    s2 = SplitBy[s1, First];
    km = Length[s2];
    ik = Table[{i[k], 1, Length[s2[[k]]]}, {k, 1, km}];
    s3 = Table[Table[s2[[k, i[k]]], {k, 1, km}], Evaluate[Sequence @@ ik]] //
       Flatten[#, km-1]&;
    s4 = Select[s3, Length[Union[Flatten[#]]] == 2km&];
    s4 // Length];
    Table[Print[n, " ", a[n]]; a[n], {n, 1, 20}] (* Jean-François Alcover, Aug 10 2022 *)
  • PARI
    a(n)=matpermanent(matrix((n+1)\2,(n+1)\2,i,j,isprime((i+j-2)*2+n+3-(n%2)))); \\ Martin Fuller, Sep 21 2023

Formula

a(2n) = A071059(2n).

Extensions

More terms from David W. Wilson, May 27 2002
a(31)-a(36) from Donovan Johnson, Aug 12 2010
Showing 1-2 of 2 results.