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.

A338869 Shortest most frequent distance among first n primes.

This page as a plain text file.
%I A338869 #20 Dec 02 2020 03:18:54
%S A338869 1,1,2,2,2,2,2,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,30,
%T A338869 30,30,30,6,30,6,6,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
%U A338869 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30
%N A338869 Shortest most frequent distance among first n primes.
%C A338869 Conjecture: Shortest most frequent distance among first n primes is a primorial number (A002110) for n>1.
%C A338869 This sequence is quite related to A338238 with which it shares many terms.
%C A338869 The corresponding frequencies of the most frequent distances among n first primes are in A283371.
%H A338869 Andres Cicuttin, <a href="/A338869/a338869.png">Log-log plot of the first 2^12 terms</a>
%e A338869 For n = 2, the distance between the first two primes 2 and 3 is 1, so the only possible distance is also the most frequent one, then a(2) = 1.
%e A338869 For n = 3, the distances between the first three primes 2, 3 and 5 are 1 = 3 - 2, 3 = 5 - 2, and 2 = 5 - 3, so all three distances are different, have the same frequency, and the shortest among them is 1, then a(3) = 1.
%e A338869 For n = 4, the five different distances between the first four primes 2, 3, 5 and 7 are 1 = 3 - 2, 2 = 5 - 3 = 7 - 5, 3 = 7 - 4 , 4 = 7 - 3 and 5 = 7 - 2, then a(3) = 2 because 2 is the most common distance (two cases) compared with the other distances which appear only once.
%e A338869 For n = 32, the most frequent distances are 30 and 6, and both appear with the same frequency (19 cases), then a(32) = 6 because 6 is the shortest between 30 and 6.
%t A338869 a[n_]:=Module[{pset, p2s,diffp2s,sd,sdgb,sdgbst},
%t A338869 pset=Prime[Range[n]]; (* First n primes *)
%t A338869 p2s=Subsets[pset,{2}]; (* All possible pairs of primes *)
%t A338869 (* Compute all possible distances and the corresponding frequencies *)
%t A338869 diffp2s=Map[Differences,p2s]//Flatten//Tally ;
%t A338869 (* Sort pairs {distance, frequency} by decreasing frequency *)
%t A338869 sd=Sort[diffp2s,#1[[2]]>#2[[2]]&];
%t A338869 (* Gather pairs {dist, freq} with same maximum frequency *)
%t A338869 sdgb=GatherBy[sd,sd[[1]][[2]]==#[[2]] &];
%t A338869 (* Sort selected pairs {dist, freq} with maximum frequency according to increasing distance *)
%t A338869 sdgbst=Sort[sdgb[[1]],#1[[1]]<#2[[1]]&];
%t A338869 (* Finally select and return the minimum distance among those with same maximum frequency *)
%t A338869 sdgbst[[1]][[1]] //Return];
%t A338869 Table[a[n],{n,2,100}]
%Y A338869 Cf. A338238, A002110, A299111, A283371.
%K A338869 nonn
%O A338869 2,3
%A A338869 _Andres Cicuttin_, Nov 13 2020