OFFSET
1,4
COMMENTS
Clearly, a(n) is also the permanent of the matrix of order n whose (i,j)-entry is 1 or 0 according as prime(i) + prime(j) + 1 is prime or not.
Conjecture: a(n) > 0 for all n > 0.
Note that there is no permutation f of {1,...,10} such that prime(k) + prime(f(k)) - 1 is prime for every k = 1,...,10.
LINKS
Zhi-Wei Sun, Permutations pi with p_k+p_{pi(k)}+1 prime for all k = 1,...,n, Question 315581 on Mathoverflow, Nov. 17, 2018.
EXAMPLE
a(3) = 1, and (1,2,3) is a permutation of {1,2,3} with prime(1) + prime(1) + 1 = 5, prime(2) + prime(2) + 1 = 7 and prime(3) + prime(3) + 1 = 11 all prime.
a(4) = 2. In fact, (1,2,4,3) is a permutation of {1,2,3,4} with prime(1) + prime(1) + 1 = 5, prime(2) + prime(2) + 1 = 7, prime(3) + prime(4) + 1 = 13 and prime(4) + prime(3) + 1 = 13 all prime; also (1,4,3,2) is a permutation of {1,2,3,4} with prime(1) + prime(1) + 1 = 5, prime(2) + prime(4) + 1 = 11, prime(3) + prime(3) + 1 = 11 and prime(4) + prime(2) + 1 = 11 all prime.
MAPLE
b:= proc(s) option remember; (k-> `if`(k=0, 1, add(`if`(isprime(
ithprime(i)+ithprime(k)+1), b(s minus {i}), 0), i=s)))(nops(s))
end:
a:= n-> b({$1..n}):
seq(a(n), n=1..15); # Alois P. Heinz, Nov 17 2018
MATHEMATICA
p[n_]:=p[n]=Prime[n];
a[n_]:=a[n]=Permanent[Table[Boole[PrimeQ[p[i]+p[j]+1]], {i, 1, n}, {j, 1, n}]];
Do[Print[n, " ", a[n]], {n, 1, 22}]
PROG
(PARI) a(n) = matpermanent(matrix(n, n, i, j, ispseudoprime(prime(i)+prime(j)+1))); \\ Jinyuan Wang, Jun 13 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Zhi-Wei Sun, Nov 17 2018
EXTENSIONS
a(23)-a(26) from Alois P. Heinz, Nov 17 2018
a(27)-a(28) from Jinyuan Wang, Jun 13 2020
a(29)-a(36) from Vaclav Kotesovec, Aug 19 2021
STATUS
approved