A018252
The nonprime numbers: 1 together with the composite numbers, A002808.
Original entry on oeis.org
1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88
Offset: 1
- G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954, p. 2.
-
A018252 := Difference([1..10^5], Filtered([1..10^5], IsPrime)); # Muniru A Asiru, Oct 21 2017
-
a018252 n = a018252_list !! (n-1)
a018252_list = filter ((== 0) . a010051) [1..]
-- Reinhard Zumkeller, Mar 31 2014
-
[n : n in [1..100] | not IsPrime(n) ];
-
with(numtheory); sort(convert(convert([ seq(i,i=1..541) ],set) minus convert([ seq(ithprime(i),i=1..100) ],set),list));
seq(`if`(not isprime(n),n,NULL),n=1..88); # Peter Luschny, Jul 29 2009
A018252 := proc(n) option remember; if n = 1 then 1; else for a from procname(n-1)+1 do if not isprime(a) then return a; end if; end do; end if; end proc: # R. J. Mathar, Oct 22 2010
-
nonPrime[n_Integer] := FixedPoint[n + PrimePi@# &, n + PrimePi@ n]; Array[ nonPrime, 75] (* Robert G. Wilson v, Jan 29 2015, based on the algorithm by Labos Elemer in A006508 *)
max = 90; Complement[Range[max], Prime[Range[PrimePi[max]]]] (* Harvey P. Dale, Aug 12 2011 *)
Join[{1}, Select[Range[100], CompositeQ]] (* Jean-François Alcover, Nov 07 2021 *)
-
isA018252(n) = !isprime(n)
A018252(n) = {local(a,b);b=n;a=1;while(a!=b,a=b;b=n+primepi(a));b} \\ Michael B. Porter, Nov 06 2009
-
a(n) = my(k=0); while(-n+n-=k-k=primepi(n), ); n; \\ Ruud H.G. van Tol, Jul 15 2024 (after code in A002808)
-
from sympy import isprime
def ok(n): return not isprime(n)
print([k for k in range(1, 89) if ok(k)]) # Michael S. Branicky, Nov 10 2022
-
from sympy import composite
def A018252(n): return 1 if n == 1 else composite(n-1) # Chai Wah Wu, Nov 15 2022
-
def A018252_list(n) :
return [k for k in (1..n) if not k.is_prime()]
A018252_list(88) # Peter Luschny, Feb 03 2012
A236854
Self-inverse permutation of natural numbers: a(1)=1, then a(p_n)=c_{a(n)}, a(c_n)=p_{a(n)}, where p_n = n-th prime, c_n = n-th composite.
Original entry on oeis.org
1, 4, 9, 2, 16, 7, 6, 23, 3, 53, 26, 17, 14, 13, 83, 5, 12, 241, 35, 101, 59, 43, 8, 41, 431, 11, 37, 1523, 75, 149, 39, 547, 277, 191, 19, 179, 27, 3001, 31, 157, 24, 12763, 22, 379, 859, 167, 114, 3943, 1787, 1153, 67, 1063, 10, 103, 27457, 127, 919, 89, 21
Offset: 1
a(5)=c(a(3))=c(9)=16, because 5=prime(3), and the 9th composite number is c(9)=16.
Thus a(10)=prime(a(5))=prime(16)=53 (since 10 is the 5th composite), a(18)=prime(a(10))=prime(53)=241 (since 18 is the 10th composite), a(28)=prime(a(18))=prime(241)=1523.
A significant record value is a(198) = prime(a(152)) = prime(563167303) since 198=c(152); a(152)=prime(a(115)) since 152=c(115); a(115)=prime(a(84)); a(84)=prime(a(60)); a(60)=prime(a(42)); a(42)=prime(a(28)).
Differs from
A135044 for the first time at n=8, where
A135044(8)=13, while here a(8)=23.
-
terms = 150; cc = Select[Range[4, 2 terms^2(*empirical*)], CompositeQ]; compositePi[k_?CompositeQ] := FirstPosition[cc, k][[1]]; a[1] = 1; a[p_?PrimeQ] := a[p] = cc[[a[PrimePi[p]]]]; a[k_] := a[k] = Prime[a[ compositePi[k]]]; Array[a, terms] (* Jean-François Alcover, Mar 02 2016 *)
-
A236854(n)={if(isprime(n), A002808(A236854(primepi(n))), n==1&&return(1);prime(A236854(n-primepi(n)-1)))} \\ without memoization: not much slower. - M. F. Hasler, Feb 03 2014
-
a236854=vector(999);a236854[1]=1;A236854(n)={a236854[n]&&return(a236854[n]); a236854[n]=if(isprime(n), A002808(A236854(primepi(n))), prime(A236854(n-primepi(n)-1)))} \\ Version with memoization. - M. F. Hasler, Feb 03 2014
-
from sympy import primepi, prime, isprime
def a002808(n):
m, k = n, primepi(n) + 1 + n
while m != k: m, k = k, primepi(k) + 1 + n
return m # this function from Chai Wah Wu
def a(n): return n if n<2 else a002808(a(primepi(n))) if isprime(n) else prime(a(n - primepi(n) - 1))
print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 07 2017
A022450
a(1) = 2; a(n+1) = a(n)-th composite.
Original entry on oeis.org
2, 6, 12, 21, 33, 49, 69, 94, 125, 164, 212, 270, 339, 422, 520, 636, 774, 933, 1121, 1339, 1590, 1880, 2210, 2587, 3021, 3512, 4074, 4710, 5427, 6239, 7155, 8183, 9339, 10637, 12084, 13705, 15517, 17534, 19773, 22266, 25030, 28095, 31484, 35239, 39387, 43960
Offset: 1
- C. Kimberling, Fractal sequences and interspersions, Ars Combinatoria, vol. 45 p 157 1997.
-
g[ n_Integer ] := (k = n + PrimePi[ n ] + 1; While[ k - PrimePi[ k ] - 1, k++ ]; k); NestList[ g, 2, 45 ]
With[{cmps=Select[Range[100000],CompositeQ]},NestList[cmps[[#]]&,2,50]] (* Harvey P. Dale, Jun 24 2025 *)
A025010
a(1) = 5; a(n+1) = a(n)-th nonprime, where nonprimes begin at 4.
Original entry on oeis.org
5, 10, 18, 28, 42, 60, 84, 115, 152, 198, 253, 320, 399, 494, 605, 736, 891, 1072, 1280, 1521, 1800, 2120, 2488, 2910, 3387, 3934, 4552, 5250, 6038, 6929, 7931, 9057, 10324, 11733, 13315, 15076, 17043, 19224, 21656, 24361, 27353, 30660, 34330, 38382, 42866
Offset: 1
-
g[ n_Integer ] := (k = n + PrimePi[ n ] + 1; While[ k - PrimePi[ k ] - 1, k++ ]; k); NestList[ g, 5, 45 ]
A025011
a(1) = 7; a(n+1) = a(n)-th composite.
Original entry on oeis.org
7, 14, 24, 36, 52, 74, 100, 133, 174, 222, 284, 356, 442, 543, 665, 805, 969, 1161, 1383, 1643, 1939, 2278, 2665, 3108, 3614, 4189, 4840, 5577, 6412, 7348, 8400, 9584, 10912, 12392, 14049, 15903, 17963, 20253, 22801, 25624, 28757, 32214, 36044, 40273, 44943
Offset: 1
-
g[ n_Integer ] := (k = n + PrimePi[ n ] + 1; While[ k - PrimePi[ k ] - 1, k++ ]; k); NestList[ g, 7, 45 ]
With[{cmps=Select[Range[100000],CompositeQ]},NestList[cmps[[#]]&,7,50]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jul 08 2017 *)
A135044
a(1)=1, then a(c) = p and a(p) = c, where c = T_c(r,k) and p = T_p(r,k), and where T_p contains the primes arranged in rows by the prime index chain and T_c contains the composites arranged in rows by the order of compositeness. See Formula.
Original entry on oeis.org
1, 4, 9, 2, 16, 7, 6, 13, 3, 19, 26, 17, 8, 23, 41, 5, 12, 67, 10, 29, 59, 37, 14, 83, 179, 11, 43, 331, 20, 47, 39, 109, 277, 157, 53, 431, 22, 1063, 31, 191, 15, 2221, 27, 61, 211, 71, 30, 599, 1787, 919, 241, 3001, 35, 73, 8527, 127, 1153, 79, 21, 19577, 44, 89, 283
Offset: 1
From _Andrew Weimholt_, Jan 29 2014: (Start)
More generally, takes the primes organized in an array according to the sieving process described in the Fernandez paper:
Row[1](n) = 2, 7, 13, 19, 23, ...
Row[2](n) = 3, 17, 41, 67, 83, ...
Row[3](n) = 5, 59, 179, ...
Row[4](n) = 11, 277, ...
Lets call this T_p (n, k)
Also take the composites organized in a similar manner, except we use "composite" numbered positions in our sieve:
Row[1](n) = 4, 6, 8, 10, 14, 20, 22, ...
Row[2](n) = 9, 12, 15, 18, 24, ...
Row[3](n) = 16, 21, 25, ...
Lets call this T_c (n, k)
If we now take the natural numbers and swap each number (except for 1) with the number which holds the same spot in the other array, then we get the sequence: 1, 4, 9, 2, 16, 7, 6, 13, with for example a(8) = 13 (13 holds the same position in the 'prime' table as 8 does in the 'composite' table). (End)
Cf.
A000040,
A007097,
A049076,
A049078 -
A049081,
A058322,
A058324 -
A058328,
A093046,
A002808,
A006508,
A059981,
A078442,
A236854.
-
A135044 := proc(n)
if n = 1 then
1;
elif isprime(n) then
idx := -1 ;
for r from 1 do
for c from 1 do
if A236542(r,c) = n then
idx := [r,c] ;
end if;
if A236542(r,c) >= n then
break;
end if;
end do:
if type(idx,list) then
break;
end if;
end do:
A236536(r,c) ;
else
idx := -1 ;
for r from 1 do
for c from 1 do
if A236536(r,c) = n then
idx := [r,c] ;
end if;
if A236536(r,c) >= n then
break;
end if;
end do:
if type(idx,list) then
break;
end if;
end do:
A236542(r,c) ;
end if;
end proc: # R. J. Mathar, Jan 28 2014
-
Composite[n_Integer] := Block[{k = n + PrimePi@n + 1}, While[k != n + PrimePi@k + 1, k++ ]; k]; Compositeness[n_] := Block[{c = 1, k = n}, While[ !(PrimeQ@k || k == 1), k = k - 1 - PrimePi@k; c++ ]; c]; Primeness[n_] := Block[{c = 1, k = n}, While[ PrimeQ@k, k = PrimePi@k; c++ ]; c];
ckj[k_, j_] := Select[ Table[Composite@n, {n, 10000}], Compositeness@# == j &][[k]]; pkj[k_, j_] := Select[ Table[Prime@n, {n, 3000}], Primeness@# == j &][[k]]; f[0]=0; f[1] = 1;
f[n_] := If[ PrimeQ@ n, pn = Primeness@n; ckj[ Position[ Select[ Table[ Prime@ i, {i, 150}], Primeness@ # == pn &], n][[1, 1]], pn], cn = Compositeness@n; pkj[ Position[ Select[ Table[ Composite@ i, {i, 500}], Compositeness@ # == cn &], n][[1, 1]], cn]]; Array[f, 64] (* Robert G. Wilson v *)
A236536
Array T(n,k) read along antidiagonals: the composites of order of compositeness n in row n.
Original entry on oeis.org
4, 6, 9, 8, 12, 16, 10, 15, 21, 26, 14, 18, 25, 33, 39, 20, 24, 28, 38, 49, 56, 22, 32, 36, 42, 55, 69, 78, 27, 34, 48, 52, 60, 77, 94, 106, 30, 40, 50, 68, 74, 84, 105, 125, 141, 35, 45, 57, 70, 93, 100, 115, 140, 164, 184, 44, 51, 64, 80, 95, 124, 133, 152, 183, 212, 236, 46, 63, 72, 88, 110, 126, 162, 174, 198, 235, 270, 299
Offset: 1
The array starts:
4, 6, 8, 10, 14, 20, 22, 27, 30, 35,...
9, 12, 15, 18, 24, 32, 34, 40, 45, 51,...
16, 21, 25, 28, 36, 48, 50, 57, 64, 72,...
26, 33, 38, 42, 52, 68, 70, 80, 88, 98,...
39, 49, 55, 60, 74, 93, 95,110,119,130,...
56, 69, 77, 84,100,124,126,145,156,170,...
78, 94,105,115,133,162,165,188,203,218,...
106,125,140,152,174,209,213,242,259,278,...
141,164,183,198,222,266,272,305,326,348,...
-
A236536 := proc(n,k)
option remember ;
if n = 1 then
A022449(k) ;
else
A002808(procname(n-1,k)) ;
end if:
end proc:
for d from 2 to 10 do
for k from d-1 to by -1 do
printf("%3d,",A236536(d-k,k)) ;
end do:
end do:
-
Composite[n_] := FixedPoint[n + PrimePi[#] + 1&, n + PrimePi[n] + 1];
T[n_, k_] := T[n, k] = If[n == 1, Composite[If[k == 1, 1, Prime[k - 1]]], Composite[T[n - 1, k]]];
Table[T[n - k + 1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Sep 16 2023 *)
A022451
a(1) = 3; a(n+1) = a(n)-th composite.
Original entry on oeis.org
3, 8, 15, 25, 38, 55, 77, 105, 140, 183, 235, 298, 372, 462, 566, 692, 838, 1007, 1205, 1432, 1698, 2002, 2352, 2755, 3210, 3731, 4322, 4990, 5747, 6601, 7562, 8638, 9854, 11211, 12731, 14422, 16315, 18425, 20765, 23372, 26258, 29460, 32998, 36912, 41229
Offset: 1
- C. Kimberling, Fractal sequences and interspersions, Ars Combinatoria, vol. 45 p 157 1997.
-
g[ n_Integer ] := (k = n + PrimePi[ n ] + 1; While[ k - PrimePi[ k ] - 1, k++ ]; k); NestList[ g, 3, 45 ]
With[{comps=Complement[Range[80000],Prime[Range[PrimePi[80000]]]]}, NestList[comps[[#+1]]&,3,50]] (* Harvey P. Dale, Mar 17 2012 *)
A059407
a(n+1) = a(n)-th composite number, with a(1) = 11.
Original entry on oeis.org
11, 20, 32, 48, 68, 93, 124, 162, 209, 266, 334, 415, 513, 628, 764, 922, 1108, 1325, 1574, 1858, 2186, 2562, 2992, 3480, 4038, 4670, 5379, 6184, 7094, 8115, 9263, 10552, 11991, 13600, 15400, 17403, 19629, 22107, 24856, 27902, 31275, 35008
Offset: 1
-
g[ n_Integer ] := (k = n + PrimePi[ n ] + 1; While[ k - PrimePi[ k ] - 1, k++ ]; k); NestList[ g, 11, 45 ]
Module[{c=Select[Range[500000],CompositeQ]},NestList[c[[#]]&,11,50]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Sep 12 2019 *)
-
lista(nn) = {print1(a = 11, ", "); nb = 0; forcomposite(c=1, nn, nb++; if (nb==a, print1(c, ", "); a = c););} \\ Michel Marcus, May 14 2018
A059408
a(n+1) = a(n)-th composite and a(1) = 13.
Original entry on oeis.org
13, 22, 34, 50, 70, 95, 126, 165, 213, 272, 341, 424, 524, 640, 778, 938, 1127, 1345, 1596, 1886, 2217, 2596, 3031, 3523, 4086, 4724, 5445, 6259, 7176, 8205, 9364, 10666, 12118, 13744, 15560, 17583, 19827, 22328, 25099, 28171, 31569, 35334
Offset: 1
-
g[ n_Integer ] := (k = n + PrimePi[ n ] + 1; While[ k - PrimePi[ k ] - 1, k++ ]; k); NestList[ g, 13, 45 ]
-
lista(nn) = {print1(a = 13, ", "); nb = 0; forcomposite(c=1, nn, nb++; if (nb==a, print1(c, ", "); a = c););} \\ Michel Marcus, May 14 2018
Showing 1-10 of 20 results.
Comments