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.

A336409 Distance from prime(n) to the nearest odd composite that is < prime(n).

Original entry on oeis.org

2, 4, 2, 4, 2, 2, 4, 2, 2, 4, 2, 2, 2, 4, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2, 2, 2, 4, 2, 4, 2, 2, 2, 2, 2, 4, 2, 4, 2, 4, 2, 2, 2, 4, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2, 2, 2, 2, 4
Offset: 5

Views

Author

Clark Kimberling, Sep 06 2020

Keywords

Examples

			Beginning with prime(5) = 11:  11-9 = 2, 13-9 = 4, 17-15 = 2, 19-15 = 4.
		

Crossrefs

Programs

  • Maple
    A336409 := proc(n)
        local p;
        p := ithprime(n) ;
        for a from p-2 by -2 do
            if not isprime(a) then
                return p-a ;
            end if;
        end do:
    end proc:
    seq(A336409(n),n=5..100) ; # R. J. Mathar, Oct 02 2020
    # second Maple program:
    a:= n-> `if`(isprime(ithprime(n)-2), 4, 2):
    seq(a(n), n=5..100);  # Alois P. Heinz, Oct 02 2020
  • Mathematica
    z = 5000; d = Select[Range[2, z], ! PrimeQ@# && OddQ@# &];  (* A014076 *)
    f[n_] := Select[d, # < Prime[n] &];
    t = Table[Prime[n] - Max[f[n]], {n, 5, 300}]  (* A336409 *)
    Flatten[Position[t, 2]]  (* A336410 *)
    Flatten[Position[t, 4]]  (* A336411 *)

Formula

a(n) = 2 * A175191(n-1). - Alois P. Heinz, Oct 02 2020
a(n) = 2 * (A062301(n) + 1). - Hugo Pfoertner, Oct 02 2020