login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Inverse permutation to A283312.
3

%I #15 Apr 04 2023 03:21:53

%S 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,

%T 30,31,32,34,35,37,38,20,39,40,41,23,43,44,45,47,48,50,51,27,52,54,55,

%U 56,57,58,59,61,62,63,64,33,65,67,68,36,70,71,72,73,74,76,77,78,79,81,82

%N Inverse permutation to A283312.

%H N. J. A. Sloane, <a href="/A338362/b338362.txt">Table of n, a(n) for n = 1..10000</a>

%F Let g(n) = A338363(n) = n + pi(n) - pi(n/2), where pi = A000720.

%F 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).

%p g := m -> m+pi(m)-pi(m/2); # A338363

%p A338362 := proc(n) global g;

%p if isprime(n) then return(g(n)-1); fi;

%p if type(n,even) then

%p if isprime(n/2) then return(g(n/2)); fi;

%p fi;

%p return(g(n)); end proc;

%p [seq(A338362(n),n=1..128)];

%t g[n_] := n + PrimePi[n] - PrimePi[n/2];

%t a[n_] := Which[PrimeQ[n], g[n]-1, PrimeQ[n/2], g[n/2], True, g[n]];

%t Table[a[n], {n, 1, 128}] (* _Jean-François Alcover_, Apr 04 2023 *)

%Y Cf. A000720, A283312, A338363.

%K nonn

%O 1,2

%A _N. J. A. Sloane_, Nov 03 2020