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.

A073452 a(n) is the number of essentially different ways in which the integers 1,2,3,...,n can be arranged in a sequence such that all pairs of adjacent integers sum to a prime number. Rotations and reversals are counted only once.

This page as a plain text file.
%I A073452 #11 Jul 19 2023 07:30:45
%S A073452 1,1,1,1,2,3,12,16,70,232,1072,3136,11648,18388,95772,452136,2047488,
%T A073452 5565488,22802028,60841609,337801784,2116714332,11425028900,
%U A073452 69023494710,429917269469
%N A073452 a(n) is the number of essentially different ways in which the integers 1,2,3,...,n can be arranged in a sequence such that all pairs of adjacent integers sum to a prime number. Rotations and reversals are counted only once.
%C A073452 Note that when the first and last numbers of an arrangement sum to a prime, then there are n rotations that are treated as one arrangement. The case n=6 exhibits rotational solutions: {1,4,3,2,5,6}, which is actually a prime circle. See A051252 for more details about prime circles.
%C A073452 The Mathematica program uses a backtracking algorithm to count the arrangements. To print the unique arrangements, remove the comments from around the print statement. It seems that a greedy algorithm can be used to quickly find a solution for any n.
%H A073452 Carlos Rivera, <a href="http://www.primepuzzles.net/conjectures/conj_020.htm">Conjecture 20. The first N natural numbers listed in an order such that the sum of each two adjacent of them is a prime number, and the Rivera's Algorithm</a>, The Prime Puzzles & Problems Connection.
%H A073452 Carlos Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_189.htm">Puzzle 189. Squares and primes in a row</a>, The Prime Puzzles & Problems Connection.
%e A073452 a(5)=2 because there are two essential different arrangements: {1,4,3,2,5} and {3,4,1,2,5}.
%t A073452 nMax=12; $RecursionLimit=500; try[lev_] := Module[{t, j, circular}, If[lev>n, circular=PrimeQ[soln[[1]]+soln[[n]]]; If[(!circular&&soln[[1]]<soln[[n]])||(circular&&soln[[1]]==1&&soln[[2]]<=soln[[n]]), (*Print[soln]; *)cnt++ ], (*else append another number to the soln list*) t=soln[[lev-1]]; For[j=1, j<=Length[s[[t]]], j++, If[ !MemberQ[soln, s[[t]][[j]]], soln[[lev]]=s[[t]][[j]]; try[lev+1]; soln[[lev]]=0]]]]; For[lst={1}; n=2, n<=nMax, n++, s=Table[{}, {n}]; For[i=1, i<=n, i++, For[j=1, j<=n, j++, If[i!=j&&PrimeQ[i+j], AppendTo[s[[i]], j]]]]; soln=Table[0, {n}]; For[cnt=0; i=1, i<=n, i++, soln[[1]]=i; try[2]]; AppendTo[lst, cnt]]; lst
%Y A073452 Cf. A073451, A051252.
%K A073452 hard,more,nice,nonn
%O A073452 1,5
%A A073452 _T. D. Noe_, Aug 02 2002
%E A073452 a(21)-a(25) from _Martin Ehrenstein_, Jul 19 2023