login
Max(i,j), where p(i)*p(j) is the n-th term of A006881.
42

%I #16 Oct 24 2024 09:26:21

%S 2,3,4,3,4,5,6,5,7,4,8,6,9,7,5,8,10,11,6,9,12,5,13,7,14,10,6,11,15,8,

%T 16,12,9,17,7,18,13,14,8,19,15,20,6,10,21,11,22,16,9,23,17,24,18,12,7,

%U 25,19,26,10,13,27,8,20,28,14,11,29,21,7,30,15,22

%N Max(i,j), where p(i)*p(j) is the n-th term of A006881.

%H Clark Kimberling, <a href="/A270652/b270652.txt">Table of n, a(n) for n = 1..1000</a>

%e A006881 = (6, 10, 14, 15, 21, 22, 26, 33, 34, 35, 38, ... ), the increasing sequence of all products of distinct primes. The first 4 factorizations are 2*3, 2*5, 2*7, 3*5, so that (a(1), a(2), a(3), a(4)) = (2,3,4,3).

%t mx = 350; t = Sort@Flatten@Table[Prime[n]*Prime[m], {n, Log[2, mx/3]}, {m, n + 1, PrimePi[mx/Prime[n]]}]; (* A006881, _Robert G. Wilson v_, Feb 07 2012 *)

%t u = Table[FactorInteger[t[[k]]][[1]], {k, 1, Length[t]}];

%t u1 = Table[u[[k]][[1]], {k, 1, Length[t]}] (* A096916 *)

%t PrimePi[u1] (* A270650 *)

%t v = Table[FactorInteger[t[[k]]][[2]], {k, 1, Length[t]}];

%t v1 = Table[v[[k]][[1]], {k, 1, Length[t]}] (* A070647 *)

%t PrimePi[v1] (* A270652 *)

%t d = v1 - u1 (* A176881 *)

%t Map[PrimePi[FactorInteger[#][[-1, 1]]] &, Select[Range@ 240, And[SquareFreeQ@ #, PrimeOmega@ # == 2] &]] (* _Michael De Vlieger_, Apr 25 2016 *)

%o (Python)

%o from math import isqrt

%o from sympy import primepi, primerange, primefactors

%o def A270652(n):

%o def bisection(f,kmin=0,kmax=1):

%o while f(kmax) > kmax: kmax <<= 1

%o while kmax-kmin > 1:

%o kmid = kmax+kmin>>1

%o if f(kmid) <= kmid:

%o kmax = kmid

%o else:

%o kmin = kmid

%o return kmax

%o def f(x): return int(n+x+(t:=primepi(s:=isqrt(x)))+(t*(t-1)>>1)-sum(primepi(x//k) for k in primerange(1, s+1)))

%o return primepi(max(primefactors(bisection(f,n,n)))) # _Chai Wah Wu_, Oct 23 2024

%Y Cf. A000040, A006881, A096916, A270650, A070647, A270003.

%K nonn,easy,changed

%O 1,1

%A _Clark Kimberling_, Apr 25 2016