OFFSET
1,7
COMMENTS
Number of ways to arrange numbers from 1 to n in a row, starting with 1 and ending with n, such that the sum of every two adjacent numbers is prime.
From Daniel Forgues, May 18 2011: (Start)
Since the sum of any two adjacent entries is at least 3, the sum is thus an odd prime, which implies that any two consecutive entries have opposite parity. Since the first and last entries of row n are fixed to 1 and n, we have to find n-2 entries, where ceiling((n-2)/2) are even and floor((n-2)/2) are odd, so for row n the number of arrangements to investigate is
(ceiling((n-2)/2))! * (floor((n-2)/2))! (Cf. A010551(n-2), n >= 2.)
Prime pyramids are also (more fittingly?) called prime triangles. (End)
REFERENCES
R. K. Guy, Unsolved Problems Number Theory, C1.
LINKS
Eric Weisstein's World of Mathematics, Prime Triangle.
EXAMPLE
a(8)=4 because of the 720 permutations P of {1,2,3,4,5,6,7,8} with first element 1 and last element 8, these four satisfy the "prime pyramid" condition that P[i] + P[i+1] be prime for i=1..7:
1 2 3 4 7 6 5 8; (lexicographically earliest row 8)
1 2 5 6 7 4 3 8;
1 4 7 6 5 2 3 8;
1 6 7 4 3 2 5 8.
For row 8, there are 6! = 720 permutations of {2,3,4,5,6}, but if we take into account that the parity of all entries of row n must alternate, we only have to consider ceiling((8-2)/2)! * floor((8-2)/2)! = 36 cases.
MATHEMATICA
prsQ[n_]:=AllTrue[Total/@Partition[n, 2, 1], PrimeQ]; Table[Count[Join[{1}, #, {n}]&/@ Permutations[ Range[2, n-1]], _?prsQ], {n, 12}] (* Harvey P. Dale, May 07 2023 *)
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
EXTENSIONS
More terms from Jud McCranie
a(25)-a(27) from Max Alekseyev, Jan 05 2008
a(28)-a(29) from Giovanni Resta, Apr 01 2014
STATUS
approved