This site is supported by donations to The OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A103839 Number of permutations of (1,2,3,...,n) where each of the (n-1) adjacent pairs of elements sums to a prime. 3
 1, 2, 2, 8, 4, 16, 24, 60, 140, 1328, 2144, 17536, 23296, 74216, 191544, 2119632, 4094976, 24223424, 45604056, 241559918, 675603568, 8723487720, 22850057800, 285146572432, 859834538938, 8276479696196, 32343039694056, 429691823372130 (list; graph; refs; listen; history; text; internal format)
 OFFSET 1,2 LINKS FORMULA For n>1, A103839(n)=2*A051239(n). EXAMPLE For n = 5, we have the 4 permutations and the sums of adjacent elements: 1,4,3,2,5 (1+4=5, 4+3=7, 3+2=5, 2+5=7) 3,4,1,2,5 (3+4=7, 4+1=5, 1+2=3, 2+5=7) 5,2,1,4,3 (5+2=7, 2+1=3, 1+4=5, 4+3=7) 5,2,3,4,1 (5+2=7, 2+3=5, 3+4=7, 4+1=5) PROG (PARI) okperm(perm) = {for (k=1, #perm -1, if (! isprime(perm[k]+perm[k+1]), return (0)); ); return (1); } a(n) = {nbok = 0; for (j=1, n!, perm = numtoperm(n, j); if (okperm(perm), nbok++); ); return (nbok); } \\ Michel Marcus, Apr 08 2013 CROSSREFS Cf. A051252 Sequence in context: A144847 A143625 A003612 * A135727 A274449 A075101 Adjacent sequences:  A103836 A103837 A103838 * A103840 A103841 A103842 KEYWORD nonn AUTHOR N. J. A. Sloane, Mar 30 2005 EXTENSIONS More terms from Max Alekseyev, Jan 04 2008 a(25)-a(28) from Giovanni Resta, Apr 01 2014 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.