cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A338362 Inverse permutation to A283312.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Nov 03 2020

Keywords

Crossrefs

Programs

  • 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 *)

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