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.

A337877 Numbers of the form p^2*q where p and q are primes and p <= q.

This page as a plain text file.
%I A337877 #15 Aug 30 2024 02:53:17
%S A337877 8,12,20,27,28,44,45,52,63,68,76,92,99,116,117,124,125,148,153,164,
%T A337877 171,172,175,188,207,212,236,244,261,268,275,279,284,292,316,325,332,
%U A337877 333,343,356,369,387,388,404,412,423,425,428,436,452,475,477,508,524,531,539,548,549,556,575,596,603
%N A337877 Numbers of the form p^2*q where p and q are primes and p <= q.
%H A337877 Robert Israel, <a href="/A337877/b337877.txt">Table of n, a(n) for n = 1..10000</a>
%e A337877 a(3) = 20 is a term because 20=2^2*5 with 2 <= 5.
%p A337877 N:= 3000: # for terms <= N
%p A337877 P:= select(isprime, [2,seq(i,i=3..N/2,2)]): nP:= nops(P):
%p A337877 R:= NULL:
%p A337877 for i from 1 to nP do
%p A337877   p2:= P[i]^2;
%p A337877   for j from i to nP do
%p A337877     x:= p2*P[j];
%p A337877     if x > N then break fi;
%p A337877     R:= R, x
%p A337877 od od:
%p A337877 sort([R]);
%o A337877 (Python)
%o A337877 from sympy import primepi, primerange, integer_nthroot
%o A337877 def A337877(n):
%o A337877     def f(x): return int(n+x-sum(primepi(x//k**2)-a for a,k in enumerate(primerange(integer_nthroot(x,3)[0]+1))))
%o A337877     def bisection(f,kmin=0,kmax=1):
%o A337877         while f(kmax) > kmax: kmax <<= 1
%o A337877         while kmax-kmin > 1:
%o A337877             kmid = kmax+kmin>>1
%o A337877             if f(kmid) <= kmid:
%o A337877                 kmax = kmid
%o A337877             else:
%o A337877                 kmin = kmid
%o A337877         return kmax
%o A337877     return bisection(f) # _Chai Wah Wu_, Aug 29 2024
%Y A337877 Contained in A337806.
%K A337877 nonn
%O A337877 1,1
%A A337877 _Robert Israel_, Sep 27 2020