I'm trying to make a function to calculate the Log sum of primes over a limited range $1/2n$ to $n$ or Chebychev theta function over limited range $1/2n$ to $n$. This will be used *only* for even numbers.

To start off I'm trying to modify a function that works:

    LogSumPrime[n_] := Total[Log[Table[Prime[i], {i, PrimePi[n]}]]];

this will output as desired for `LogSumPrime[12]`:

    Log[2] + Log[3] + Log[5] + Log[7] + Log[11]

So far so good. Now modifying to get range $1/2n$ to $n$:

    LogSumAllUpperPrime[n_] := 
      Total[Log[Table[(Prime[i + PrimePi[n] - PrimePi[n/2] + 1]), 
      {i, PrimePi[n] - PrimePi[n/2]}]]];

for `LogSumAllUpperPrime[12]`, it is fine:

    Log[7] + Log[11]

for `LogSumAllUpperPrime[6]`, it is not fine:

    Log[5]

It should be `Log[3] + Log[5]`. Now the problem stems from half of 6 being odd and the limits not starting for this at 3, while for 12 it starts at 6 and the problem does not matter.

I do not understand Mathematica, so I cannot see how to solve this problem efficiently. If it were C, I'd just see if the bit is 1 or 0 to determine whether its even, but that may not be the best remedy here.

I would like to do this quite efficiently as I will be working with quite large numbers and the `Table` approach is said to be reasonably efficient.