login
Number of ways of arranging row n of the prime pyramid.
7

%I #39 Aug 07 2024 01:07:37

%S 1,1,1,1,1,1,2,4,7,24,80,216,648,1304,3392,13808,59448,155464,480728,

%T 1588162,5626309,28279112,157469880,842498189,4998554801,28466978744,

%U 166572523589,1020487969891,5753385660978

%N Number of ways of arranging row n of the prime pyramid.

%C 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.

%C From _Daniel Forgues_, May 18 2011: (Start)

%C 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

%C (ceiling((n-2)/2))! * (floor((n-2)/2))! (Cf. A010551(n-2), n >= 2.)

%C Prime pyramids are also (more fittingly?) called prime triangles. (End)

%D R. K. Guy, Unsolved Problems Number Theory, C1.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PrimeTriangle.html">Prime Triangle</a>.

%e 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:

%e 1 2 3 4 7 6 5 8; (lexicographically earliest row 8)

%e 1 2 5 6 7 4 3 8;

%e 1 4 7 6 5 2 3 8;

%e 1 6 7 4 3 2 5 8.

%e 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.

%t 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 *)

%Y Cf. A051237 for lexicographically earliest prime pyramid.

%K nonn,nice

%O 1,7

%A _John W. Layman_

%E More terms from _Jud McCranie_

%E a(25)-a(27) from _Max Alekseyev_, Jan 05 2008

%E a(28)-a(29) from _Giovanni Resta_, Apr 01 2014