login
A392408
Number of permutations p of [n] such that i + p(i) is composite for all i.
0
1, 0, 0, 1, 2, 9, 32, 189, 1368, 8210, 44148, 389912, 3101440, 35058904, 443288708, 5108994142, 55028376940, 780766798385, 11860152133970, 196801719385449, 3515777759388072, 58688432620407329, 933262343169946392, 18278243997627725158, 344317636096990851008
OFFSET
0,5
COMMENTS
Whenever n+1 is composite, a(n) > 0 since the reversal permutation p(i) = n+1-i gives all sums i + (n+1-i) = n+1.
From Michael S. Branicky, Jan 10 2026: (Start)
For n >= 3, a(n) > 0 since the permutation (3, 2, 1, 4, 5, 6, ..., n) that reverses the first three elements and leaves all others fixed has sums 4, 4, 4, 2*4, 2*5, 2*6, ..., 2*n, all of which are composite.
No permutation that leaves 1 fixed or maps 2 to 1 is counted. (End)
EXAMPLE
a(1) = 0 since 1 + 1 = 2 is prime.
a(2) = 0 since 1 + 2 = 3 is prime.
a(3) = 1 since the only valid permutation is (3,2,1) with 1+3=4, 2+2=4, 3+1=4 all composite.
a(4) = 2 since the only valid permutations are (3,2,1,4) with composite sums [4,4,4,8] and (3,4,1,2) with composite sums [4,6,4,6].
MAPLE
b:= proc(s) option remember; `if`(n=0, 1, add(
`if`(isprime(j+nops(s)), 0, b(s minus {j})), j=s))
end:
a:= n-> b({$1..n}):
seq(a(n), n=0..16); # Alois P. Heinz, Jan 10 2026
MATHEMATICA
a[n_] := Count[Permutations[Range[n]], p_ /; AllTrue[Range[n], CompositeQ[# + p[[#]]] &]]; Table[a[n], {n, 1, 10}]
PROG
(Python)
from itertools import permutations
from sympy import isprime
def a(n): return sum(1 for p in permutations(range(1, n+1)) if all(not isprime(i + p[i-1]) for i in range(1, n+1)))
print([a(n) for n in range(1, 11)])
CROSSREFS
Cf. A000040 (primes), A002808 (composite numbers), A073364, A324372.
Sequence in context: A013501 A382781 A179230 * A114853 A331727 A110376
KEYWORD
nonn
AUTHOR
Sandeep Wawdane, Jan 10 2026
EXTENSIONS
a(11)-a(15) from Michael S. Branicky, Jan 10 2026
a(16)-a(24) from Alois P. Heinz, Jan 10 2026
STATUS
approved