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-4 of 4 results.

A000341 Number of ways to pair up {1..2n} so sum of each pair is prime.

Original entry on oeis.org

1, 2, 3, 6, 26, 96, 210, 1106, 3759, 12577, 74072, 423884, 2333828, 16736611, 99838851, 630091746, 4525325020, 38848875650, 342245714017, 3335164762941, 31315463942337, 241353231085002, 2350106537365732, 17903852593938447, 158065352670318614, 1815064841856534244, 20577063085601738871, 276081763499377227299
Offset: 1

Views

Author

S. J. Greenfield (greenfie(AT)math.rutgers.edu)

Keywords

Examples

			For n=4, there are 6 ways to pair up {1, 2, 3, 4, 5, 6, 7, 8} so that each pair sums to a prime:
1+2, 3+4, 5+8, 6+7
1+2, 3+8, 4+7, 5+6
1+4, 2+3, 5+8, 6+7
1+4, 2+5, 3+8, 6+7
1+6, 2+3, 4+7, 5+8
1+6, 2+5, 3+8, 4+7
Therefore a(4) = 6. - _Michael B. Porter_, Jul 19 2016
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local M;
      M:= Matrix(n,n,(i,j) -> `if`(isprime(2*i+2*j-1),1,0));
      LinearAlgebra:-Permanent(M)
    end proc:
    map(f, [$1..20]); # Robert Israel, Jul 19 2016
  • Mathematica
    a[n_] := Permanent[ Array[ Boole[ PrimeQ[2*#1 + 2*#2 - 1]] & , {n, n}]]; Table[an = a[n]; Print[an]; an, {n, 1, 20}] (* Jean-François Alcover, Oct 21 2011, after T. D. Noe, updated Feb 07 2016 *)
  • PARI
    permRWNb(a)=n=matsize(a)[1];if(n==1,return(a[1,1]));sg=1;nc=0;in=vectorv(n);x=in;x=a[,n]-sum(j=1,n,a[,j])/2;p=prod(i=1,n,x[i]);for(k=1,2^(n-1)-1,sg=-sg;j=valuation(k,2)+1;z=1-2*in[j];in[j]+=z;nc+=z;x+=z*a[,j];p+=prod(i=1,n,x[i],sg));return(2*(2*(n%2)-1)*p)
    for(n=1,24,a=matrix(n,n,i,j,isprime(2*(i+j)-1));print1(permRWNb(a)", ")) \\ Herman Jamke (hermanjamke(AT)fastmail.fm), May 13 2007
    
  • PARI
    a(n)=matpermanent(matrix(n,n,i,j,isprime(2*(i+j)-1))); \\ Martin Fuller, Sep 22 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 2i+2j-1 is prime or composite, respectively. - T. D. Noe, Feb 10 2007

Extensions

More terms from David W. Wilson
More terms from T. D. Noe, Feb 10 2007
More terms from Herman Jamke (hermanjamke(AT)fastmail.fm), May 13 2007
More terms from Sean A. Irvine, Nov 14 2010

A342136 Number of partitions of [2n] into pairs whose sums and differences are primes.

Original entry on oeis.org

1, 0, 0, 0, 1, 2, 6, 10, 22, 101, 66, 504, 2088, 3572, 14398, 49984, 108030, 191228, 1087758, 5005440, 14081453, 97492234, 160186634, 939652634, 3926077642, 4273706733, 41832174879, 214185383046, 494248121522, 6153003414039, 38125026176659, 13635112709648, 39350572537836, 511502485322923, 1069875349612147, 5075263842958032
Offset: 0

Views

Author

Alois P. Heinz, Mar 01 2021

Keywords

Examples

			a(4) = 1: {{1,6}, {2,5}, {3,8}, {4,7}}.
a(5) = 2: {{1,6}, {2,9}, {3,10}, {4,7}, {5,8}}, {{1,6}, {2,5}, {3,8}, {4,9}, {7,10}}.
		

Crossrefs

Programs

  • Maple
    b:= proc(s) option remember; `if`(s={}, 1, (j-> add(`if`(i b({$1..2*n}):
    seq(a(n), n=0..15);
  • Mathematica
    b[s_] := b[s] = If[s == {}, 1, With[{j = Max[s]}, Sum[If[i < j && AllTrue[{j+i, j-i}, PrimeQ], b[s ~Complement~ {i, j}], 0], {i, s}]]];
    a[n_] := b[Range[2n]];
    a /@ Range[0, 15] (* Jean-François Alcover, Aug 25 2021, after Alois P. Heinz *)

Extensions

a(25)-a(35) from Bert Dobbelaere, Mar 06 2021

A342139 Number of partitions of [2n] into pairs whose sums or differences are primes.

Original entry on oeis.org

1, 1, 3, 8, 28, 167, 810, 4664, 38344, 207255, 2059900, 19385131, 174417011, 1922011637, 21058799803, 208257199434, 2905150193223, 38462668421772, 481607876817202, 7526871509864950
Offset: 0

Views

Author

Alois P. Heinz, Mar 01 2021

Keywords

Examples

			a(2) = 3: {{1,4}, {2,3}}, {{1,3}, {2,4}}, {{1,2}, {3,4}}.
		

Crossrefs

Programs

  • Maple
    b:= proc(s) option remember; `if`(s={}, 1, (j-> add(`if`(i b({$1..2*n}):
    seq(a(n), n=0..15);
  • Mathematica
    b[s_] := b[s] = If[s == {}, 1, With[{j = Max[s]}, Sum[If[i < j && AnyTrue[{j+i, j-i}, PrimeQ], b[s ~Complement~ {i, j}], 0], {i, s}]]];
    a[n_] := b[Range[2n]];
    a /@ Range[0, 15] (* Jean-François Alcover, Aug 25 2021, after Alois P. Heinz *)

A342155 Number of partitions of [2n] into pairs such that either their sum or their absolute difference is a prime (but not both).

Original entry on oeis.org

1, 1, 2, 3, 7, 26, 55, 282, 1520, 2685, 27005, 171474, 768123, 5936728, 43976303, 207493790, 2570789335, 21669733984, 136340261314, 1639978185920
Offset: 0

Views

Author

Alois P. Heinz, Mar 02 2021

Keywords

Examples

			a(4) = 7:
  {{1,8}, {2,7}, {3,5}, {4,6}},
  {{1,8}, {2,7}, {3,4}, {5,6}},
  {{1,8}, {2,4}, {3,6}, {5,7}},
  {{1,8}, {2,3}, {4,6}, {5,7}},
  {{1,8}, {2,4}, {3,5}, {6,7}},
  {{1,3}, {2,4}, {5,7}, {6,8}},
  {{1,2}, {3,4}, {5,7}, {6,8}}.
		

Crossrefs

Programs

  • Maple
    b:= proc(s) option remember; `if`(s={}, 1, (j-> add(`if`(i b({$1..2*n}):
    seq(a(n), n=0..15);
  • Mathematica
    b[s_] := b[s] = If[s == {}, 1, With[{j = Max[s]}, Sum[If[i < j && (PrimeQ[j + i] ~Xor~ PrimeQ[j - i]), b[s ~Complement~  {i, j}], 0], {i, s}]]];
    a[n_] := b[Range[2n]];
    a /@ Range[0, 15] (* Jean-François Alcover, Aug 25 2021, after Alois P. Heinz *)
Showing 1-4 of 4 results.