%I #30 Jul 23 2024 15:10:19
%S 0,0,0,1,1,3,3,3,4,6,6,6,6,8,10,10,10,10,10,10,12,14,14,14,15,17,17,
%T 17,17,17,17,17,19,21,23,23,23,25,27,27,27,27,27,27,27,29,29,29,30,30,
%U 32,32,32,32,34,34,36,38,38,38,38,40,40,40,42,42,42,42,44,44,44,44,44,46
%N Partial sums of A230595.
%C Sum of the Dirichlet convolution of the characteristic function of primes (A010051) with itself from 1 to n.
%C (a(n) + A000720(floor(sqrt(n))))/2 equals the number of semiprimes <= n.
%H Alois P. Heinz, <a href="/A334940/b334940.txt">Table of n, a(n) for n = 1..20000</a>
%F a(n) = Sum_{k=1..n} Sum_{d|k} A010051(d) * A010051(k/d).
%F a(n) = 2*Sum_{p prime <= sqrt(n)} A000720(floor(n/p)) - A000720(floor(sqrt(n)))^2.
%F a(n) = 2*A072000(n) - A000720(floor(sqrt(n))).
%F a(n) = 2*A072613(n) + A000720(floor(sqrt(n))). - _Vaclav Kotesovec_, May 21 2020
%F a(n) ~ 2*n*log(log(n))/log(n). - _Vaclav Kotesovec_, May 21 2020
%p a:= proc(n) option remember; `if`(n<4, 0, a(n-1) +
%p `if`(numtheory[bigomega](n)=2, `if`(issqr(n), 1, 2), 0))
%p end:
%p seq(a(n), n=1..80); # _Alois P. Heinz_, May 20 2020
%t f[n_] := DivisorSum[n, 1 &, PrimeQ[#] && PrimeQ[n/#] &]; Accumulate @ Array[f, 100] (* _Amiram Eldar_, May 20 2020 *)
%o (PARI) a(n) = my(s=sqrtint(n)); 2*sum(k=1, s, if(isprime(k), primepi(n\k), 0)) - primepi(s)^2;
%o (Python)
%o from math import isqrt
%o from sympy import primepi, prime
%o def A334940(n): return (int(sum(primepi(n//prime(k))-k+1 for k in range(1,primepi(isqrt(n))+1)))<<1) - primepi(isqrt(n)) # _Chai Wah Wu_, Jul 23 2024
%Y Cf. A000720, A001222, A010051, A072000, A230595.
%K nonn
%O 1,6
%A _Daniel Suteu_, May 17 2020