OFFSET
0,6
LINKS
Wikipedia, Partition of a set
FORMULA
The graph on vertices [2n] and edges connecting pairs with prime sum and difference is bipartite (with odd numbers in one part and even numbers in the other). Hence, a(n) as the number of perfect matchings in this graph is given by the permanent of its reduced adjacency matrix (see PARI code). - Max Alekseyev, Sep 30 2025
EXAMPLE
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}}.
MAPLE
b:= proc(s) option remember; `if`(s={}, 1, (j-> add(`if`(i<j and
andmap(isprime, [j+i, j-i]), b(s minus {i, j}), 0), i=s))(max(s)))
end:
a:= n-> 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 *)
PROG
(PARI) a342136(n) = matpermanent( matrix(n, n, i, j, isprime(2*i-1+2*j) && isprime(abs(2*i-1-2*j))) ); \\ Max Alekseyev, Sep 30 2025
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Mar 01 2021
EXTENSIONS
a(25)-a(35) from Bert Dobbelaere, Mar 06 2021
STATUS
approved
