login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A338362
Inverse permutation to A283312.
3
1, 2, 4, 3, 6, 5, 8, 10, 11, 7, 12, 14, 15, 9, 17, 18, 19, 21, 22, 24, 25, 13, 26, 28, 29, 16, 30, 31, 32, 34, 35, 37, 38, 20, 39, 40, 41, 23, 43, 44, 45, 47, 48, 50, 51, 27, 52, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 33, 65, 67, 68, 36, 70, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82
OFFSET
1,2
LINKS
FORMULA
Let g(n) = A338363(n) = n + pi(n) - pi(n/2), where pi = A000720.
Then a(n) = g(n)-1 if n is a prime, a(n) = g(n/2) if n is twice a prime, and otherwise a(n) = g(n).
MAPLE
g := m -> m+pi(m)-pi(m/2); # A338363
A338362 := proc(n) global g;
if isprime(n) then return(g(n)-1); fi;
if type(n, even) then
if isprime(n/2) then return(g(n/2)); fi;
fi;
return(g(n)); end proc;
[seq(A338362(n), n=1..128)];
MATHEMATICA
g[n_] := n + PrimePi[n] - PrimePi[n/2];
a[n_] := Which[PrimeQ[n], g[n]-1, PrimeQ[n/2], g[n/2], True, g[n]];
Table[a[n], {n, 1, 128}] (* Jean-François Alcover, Apr 04 2023 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Nov 03 2020
STATUS
approved