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.
%I A115316 #14 Nov 16 2021 20:20:31 %S A115316 1,2,4,6,3,8,9,5,10,12,7,14,15,11,16,18,13,20,21,17,22,24,19,25,26,23, %T A115316 27,28,29,30,32,31,33,34,37,35,36,41,38,39,43,40,42,47,44,45,53,46,48, %U A115316 59,49,50,61,51,52,67,54,55,71,56,57,73,58,60,79,62,63,83,64,65,89,66 %N A115316 Lexicographically earliest permutation of the natural numbers such that each prime number is followed by exactly two composite numbers. %C A115316 Inverse: A115318. %C A115316 Fixed points = {1,2,27,28,29,30,33,34}, also for A115317, A115318, A115319. %H A115316 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A115316 a(a(n)) = A115317(n). %F A115316 a(3*n-2) = A018252(2*n-1), a(3*n-1) = A000040(n), a(3*n) = A018252(2*n); %F A115316 a(n+1+floor((n+1)/2)) = A002808(n). %t A115316 terms = 72; %t A115316 np = Ceiling[terms/3] + 1; %t A115316 nc = Ceiling[(2/3) terms]; %t A115316 pp = Prime[Range[np]]; %t A115316 cc = Partition[Select[Range[FindRoot[n == nc + PrimePi[n] + 1, {n, nc, 2nc}][[1, 2]] // Floor], CompositeQ], 2]; %t A115316 Join[{1}, Riffle[pp, cc] // Flatten][[1 ;; terms]] (* _Jean-François Alcover_, Nov 15 2021 *) %Y A115316 Cf. A002808, A018252, A073846. %Y A115316 Cf. A115317, A115318, A115319. %K A115316 nonn,easy %O A115316 1,2 %A A115316 _Reinhard Zumkeller_, Jan 20 2006