A026240
a(n) = |s(n) - n|, where s = A026239.
Original entry on oeis.org
0, 2, 3, 2, 3, 3, 2, 3, 2, 1, 1, 1, 1, 3, 4, 7, 3, 11, 4, 11, 16, 19, 7, 19, 22, 27, 32, 33, 11, 37, 11, 39, 40, 45, 48, 53, 16, 59, 62, 63, 19, 65, 19, 65, 68, 81, 22, 83, 88, 89, 98, 99, 27, 103, 108, 111, 116, 121, 32, 121, 33, 129, 130, 133
Offset: 1
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
A249990
Start with the natural numbers, reverse the order in each pair, skip one pair, reverse the order in each triple, skip one triple, and so on.
Original entry on oeis.org
2, 1, 6, 3, 4, 12, 5, 8, 7, 16, 9, 10, 13, 14, 22, 15, 18, 11, 24, 17, 32, 25, 26, 19, 20, 23, 30, 48, 31, 38, 21, 28, 27, 34, 33, 52, 35, 42, 29, 36, 39, 40, 49, 50, 58, 51, 54, 41, 44, 37, 60, 43, 66, 53, 84, 67, 68, 61, 62, 45, 46, 55, 56, 59, 76, 94, 77, 90
Offset: 1
Start with:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ...
After the first step:
2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, ...
After the 2nd step:
2, 1, 6, 3, 4, 7, 8, 5, 12, 9, 10, 13, 14, 11, 18, 15, 16, ...
After the 3rd step:
2, 1, 6, 3, 4, 12, 5, 8, 7, 14, 13, 10, 9, 16, 15, 18, 11, ...
-
a249990 n = a249990_list !! (n-1)
a249990_list = f 2 [1..] where
f k xs = reverse ys ++ f (k + 1) (g zs) where
g us = reverse vs ++ g ws where
(vs, ws) = splitAt k us
(ys, zs) = splitAt k xs
-- Reinhard Zumkeller, Dec 17 2014
-
TOP = 100
a = list(range(TOP))
for step in range(2,TOP):
numBlocks = (len(a)-1) // step
if numBlocks==0: break
a = a[:(1+numBlocks*step)]
for pos in range(1,len(a),step):
a[pos:pos+step] = a[pos+step-1:pos-1:-1]
for i in range(1, step+1): print(str(a[i]), end=',')
a[1:] = a[step+1:]
A088609
a(1) = 1, a(n) is the smallest squarefree number not included earlier if n is not squarefree, else n is the smallest nonsquarefree number.
Original entry on oeis.org
1, 4, 8, 2, 9, 12, 16, 3, 5, 18, 20, 6, 24, 25, 27, 7, 28, 10, 32, 11, 36, 40, 44, 13, 14, 45, 15, 17, 48, 49, 50, 19, 52, 54, 56, 21, 60, 63, 64, 22, 68, 72, 75, 23, 26, 76, 80, 29, 30, 31, 81, 33, 84, 34, 88, 35, 90, 92, 96, 37, 98, 99, 38, 39, 100, 104, 108, 41, 112, 116
Offset: 1
A073922
a(1) = 1, a(n) = smallest composite number greater than n and not occurring earlier if n is prime, or smallest prime number greater than n and not occurring earlier if n is composite.
Original entry on oeis.org
1, 4, 6, 5, 8, 7, 9, 11, 13, 17, 12, 19, 14, 23, 29, 31, 18, 37, 20, 41, 43, 47, 24, 53, 59, 61, 67, 71, 30, 73, 32, 79, 83, 89, 97, 101, 38, 103, 107, 109, 42, 113, 44, 127, 131, 137, 48, 139, 149, 151, 157, 163, 54, 167, 173, 179, 181, 191, 60, 193, 62, 197, 199
Offset: 1
-
p:= 1: c:= 1: R:= 1:
for n from 2 to 100 do
if isprime(n) then
c:= max(c,n)+1;
while isprime(c) do c:=c+1 od:
R:= R,c
else
p:= nextprime(max(p,n));
R:= R,p
fi
od:
R; # Robert Israel, Apr 10 2024
A249991
Start with the natural numbers, reverse the order in each pair, skip one number, reverse the order in each triple, skip one number, and so on.
Original entry on oeis.org
2, 3, 5, 10, 12, 13, 21, 26, 28, 39, 41, 46, 54, 65, 67, 82, 84, 85, 109, 114, 122, 137, 139, 160, 178, 179, 181, 222, 230, 235, 269, 274, 276, 313, 331, 336, 370, 381, 383, 424, 426, 437, 471, 476, 536, 541, 549, 554, 618, 629, 647, 704, 706, 707, 761, 818
Offset: 1
-
TOP = 100000
a = list(range(TOP))
for step in range(2,TOP):
numBlocks = (len(a)-1) // step
if numBlocks==0: break
a = a[:(1+numBlocks*step)]
for pos in range(1,len(a),step):
a[pos:pos+step] = a[pos+step-1:pos-1:-1]
print(a[1], end=', ')
a[1:] = a[2:]
A373290
a(1) = 1. Thereafter, for n prime a(n) is the smallest composite number not already a term which is not divisible by n, and for n composite a(n) is the smallest prime not already a term, which does not divide n.
Original entry on oeis.org
1, 9, 4, 3, 6, 5, 8, 7, 2, 11, 10, 13, 12, 17, 19, 23, 14, 29, 15, 31, 37, 41, 16, 43, 47, 53, 59, 61, 18, 67, 20, 71, 73, 79, 83, 89, 21, 97, 101, 103, 22, 107, 24, 109, 113, 127, 25, 131, 137, 139, 149, 151, 26, 157, 163, 167, 173, 179, 27, 181, 28, 191, 193
Offset: 1
For n = 2, (prime), a(2) = 9, the smallest composite number not divisible by 2.
For n = 6, (composite), a(6) = 5, the smallest novel prime which does not divide 6.
-
nn = 120; c[_] := False; a[1] = 1; c[1] = True; u = 2; v = 4;
Do[If[PrimeQ[n],
k = v; While[Or[c[k], PrimeQ[k], Divisible[k, n]], k++],
k = u; While[Or[c[k], CompositeQ[k], Divisible[n, k]], k++]];
Set[{a[n], c[k]}, {k, True}];
If[k == u, While[Or[c[u], CompositeQ[u]], u++]];
If[k == v, While[Or[c[v], PrimeQ[v]], v++]], {n, 2, nn}];
Array[a, nn] (* Michael De Vlieger, May 31 2024 *)
Showing 1-7 of 7 results.
Comments