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.

A336407 a(n) is the number of composites < n-th odd composite.

This page as a plain text file.
%I A336407 #21 Aug 01 2024 01:31:52
%S A336407 3,7,11,14,16,20,22,25,29,32,34,37,39,43,45,48,52,54,57,60,62,65,67,
%T A336407 69,72,76,80,83,85,87,89,91,93,96,99,101,105,107,109,111,115,117,120,
%U A336407 122,125,128,130,133,135,139,141,143,145,149,153,155,157,159,161
%N A336407 a(n) is the number of composites < n-th odd composite.
%e A336407 a(2) is the number of the numbers 4, 6, 8, 9, 10, 12, 14, these being the composites that are less than 15, which is the 2nd odd composite.
%t A336407 z = 400; p = Prime[Range[z]];
%t A336407 c = Select[Range[2, z], ! PrimeQ@# &];  (* A002808 *)
%t A336407 d = Select[Range[2, z], ! PrimeQ@# && OddQ@# &];  (* A014076 *)
%t A336407 f[n_] := Select[c, # < d[[n]] &];
%t A336407 g[n_] := d[[n]] + Select[c, # < d[[n]] &];
%t A336407 q[n_] := Length[Intersection[p, g[n]]];
%t A336407 tq = Table[q[n], {n, 1, 120}] (* A336406 *)
%t A336407 tc = Table[Length[f[n]], {n, 1, 120}] (* A336407 *)
%t A336407 m = Min[Length[tq], Length[tc]]; Take[tc, m] - Take[tq, m] (* A336408 *)
%o A336407 (PARI) n=0;forcomposite(x=4,210,if(x%2,print1(n,", "));n++) \\ _Hugo Pfoertner_, Jul 26 2020
%o A336407 (Python)
%o A336407 from sympy import primepi
%o A336407 def A336407(n):
%o A336407     if n == 1: return 3
%o A336407     m, k = n, (r:=primepi(n)) + n + (n>>1)
%o A336407     while m != k:
%o A336407         m, k = k, (r:=primepi(k)) + n + (k>>1)
%o A336407     return m-r-2 # _Chai Wah Wu_, Jul 31 2024
%Y A336407 Cf. A000040, A002808, A014076, A336406, A336408.
%K A336407 nonn
%O A336407 1,1
%A A336407 _Clark Kimberling_, Jul 20 2020