← RoseCode

ROSECODE 491

Prime permutations

Philippe_57721 · Programming ·

A permutation P of {1,2,,n} is said prime if:
  • P1=1
  • Pn=n
  • i<n,Pi+Pi+1 is a prime number
{1,6,5,8,9,2,3,4,7,10} is a prime permutation

How many prime permutations are there for n=21?

[My timing: 30 sec]