cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A367704 Number of permutations of [n] where each pair of adjacent elements differs by a prime.

This page as a plain text file.
%I A367704 #37 Dec 31 2023 00:57:45
%S A367704 1,1,0,0,2,10,32,96,448,1968,7320,21516,118938,662742,4556360,
%T A367704 26950038,155388246,756995286,5730299976,38809702892,337875402936,
%U A367704 2593543573702,20560179519176,138677553274430,1337517942958934,11083936316867572,94288296012340842
%N A367704 Number of permutations of [n] where each pair of adjacent elements differs by a prime.
%C A367704 This sequence was inspired by A103839 and the PARI program is a modified version of the one in A103839.
%C A367704 The number of Hamiltonian paths in a graph of which the nodes represent the numbers (1,2,3,...,n) and the edges connect each pair of nodes that differ by a prime.
%C A367704 A076220, A103839 and this sequence are closely related, but their combined graph in the link shows an interesting difference, notably between this sequence and the two others. - _Bob Andriesse_, Dec 03 2023
%H A367704 Bob Andriesse, <a href="/A367704/a367704_1.jpg">Combined graph of this sequence, A076220 and A103839 for a(4) to a(25)</a>
%e A367704 a(4) = 2: 2413, 3142.
%e A367704 a(5) = 10: 13524, 14253, 24135, 25314, 31425, 35241, 41352, 42531, 52413, 53142.
%o A367704 (PARI) okperm(perm) = {for (k=1, #perm -1, if (! isprime(abs(perm[k]-perm[k+1])),  return (0));  ); return (1); }
%o A367704 a(n) = {nbok = 0; for (j=1, n!, perm = numtoperm(n, j); if (okperm(perm), nbok++); ); return (nbok); }
%Y A367704 Cf. A076220, A103839.
%K A367704 nonn
%O A367704 0,5
%A A367704 _Bob Andriesse_, Nov 27 2023
%E A367704 a(14)-a(22) from _Alois P. Heinz_, Nov 27 2023
%E A367704 a(23)-a(26) from _Martin Ehrenstein_, Dec 03 2023