A067747 Primes interleaved between composite numbers: n-th prime followed by the n-th composite number.
2, 4, 3, 6, 5, 8, 7, 9, 11, 10, 13, 12, 17, 14, 19, 15, 23, 16, 29, 18, 31, 20, 37, 21, 41, 22, 43, 24, 47, 25, 53, 26, 59, 27, 61, 28, 67, 30, 71, 32, 73, 33, 79, 34, 83, 35, 89, 36, 97, 38, 101, 39, 103, 40, 107, 42, 109, 44, 113, 45, 127, 46, 131, 48, 137, 49, 139
Offset: 1
Examples
For n=4, the index is even. Therefore a(4)=A002808(4/2)=A002808(2)=6.
Links
Programs
-
Haskell
import Data.List (transpose) a067747 n = a067747_list !! (n-1) a067747_list = concat $ transpose [a000040_list, a002808_list] -- Reinhard Zumkeller, Jan 29 2014
-
Maple
P,C:= selectremove(isprime,[$2..1000]): seq(op([P[i],C[i]]),i=1..min(nops(P),nops(C))); # Robert Israel, Jul 24 2015
-
Mathematica
Array[c,1000];pc=-1;nc=0;Do[If[PrimeQ[n],If[pc==999,Break[],pc+=2;c[pc]=n],If[nc<=998,nc+=2;c[nc]=n,Goto[ne]]];Label[ne],{n,2,20000}];Table[c[i],{i,1000}] (* Zak Seidov, Mar 22 2008 *) Composite[n_Integer] := FixedPoint[n + PrimePi@ # + 1 &, n + PrimePi@ n + 1]; Table[{Prime@ n, Composite@ n}, {n, 35}] // Flatten (* Robert G. Wilson v, Jun 08 2008 *)
-
PARI
c(n) = for(k=0, primepi(n), isprime(n++)&&k--); n; \\ A002808 a(n) = if (n%2, prime((n+1)/2), c((n+1)\2)); \\ Michel Marcus, Mar 06 2021
Formula
a(n) = A000040(ceiling(n/2))*A000035(n) + A002808(ceiling(n/2))*A059841(n), equivalent to the Zumkeller formula. - Chayim Lowen, Jul 29 2015
Comments