<s>[INST] How to prove that function $f(p)= \frac{1}{(p^2 - 1)} \sum_{q=3}^p \frac{q^2-3}{q}[q\text{ is prime}]$ is less than 0.3 for all $p$? How to prove that function $f(p)= \frac{1}{(p^2 - 1)} \sum_{q=3}^p \frac{q^2-3}{q}[q\text{ is prime}]$ is less than 0.3 for all $p$?
Let's suppose that we have a function defined as follows:
$f(p) = \frac{1}{(p^2 - 1)} \sum_{q=3}^p \frac{q^2-3}{q}[q\text{ is prime}]$
where $p$ is a prime number and $[...]$ are Iverson brackets.
Here are the first few values of $f(p)$:
$f(3) = \frac{1}{(3^2 - 1)} \times \frac {(3^2-3)}{3}$
$f(3) = \frac{1}{8} \times  \frac{6}{3}$
$f(3) = 0.25$
$f(5) = \frac{1}{(5^2 - 1)} \times [ \frac{(3^2-3)}{3} +\frac{(5^2-3)}{5} ]$
$f(5) = \frac{1}{24} \times [ \frac{6}{3} +\frac{22}{5} ]$
$f(5) = 0.26667$
$f(7) = \frac{1}{(7^2 - 1)} \times [ \frac{(3^2-3)}{3} +\frac{(5^2-3)}{5} +\frac{(7^2-3)}{7}]$
$f(7) = \frac{1}{48} \times [ \frac{6}{3} +\frac{22}{5} +\frac{46}{7}]$
$f(7) = 0.273214286$
$f(11) = \frac{1}{(11^2 - 1)} \times [ \frac{(3^2-3)}{3} +\frac{(5^2-3)}{5} +\frac{(7^2-3)}{7}+\frac{(11^2-3)}{11}]$
$f(11) = \frac{1}{120} \times [ \frac{6}{3} +\frac{22}{5} +\frac{46}{7}+\frac{118}{11}]$
$f(11) = 0.198679654$
How to prove that $f(p)$ is always less than 0.3 for all prime numbers $p$?
I wrote a program to calculate $f(p)$ for the first $1000$ primes up to $p = 7,927$ and graphically it appears to approach $0$ with a maximum value of $0.2732$ at $p=7$. From the graph, it looks like it should be easy, but for some reason, I cannot figure it out.
Notice that $f(3) < f(5) < f(7)$, but $f(7) > f(11)$ so a proof by induction may not work.

 [/INST] The result is true for $p = 3$, $5$, and $7$, so assume that $p = 2n+1$ for $n \ge 4$.
Note that all the primes $q$ occurring in the sum are odd. Thus
$$
\begin{aligned}
f(p) = f(2n+1) = & \ \frac{1}{4n^2 + 4n} \sum_{q=3}^{p, \text{ with $q$ prime}} \frac{q^2 - 3}{q}\\
 < & \  \frac{1}{4(n^2 + n)} \sum_{q=3}^{p, \text{ with $q$ prime}} q \\
< & \  \frac{1}{4(n^2 + n)} \sum_{q = 3}^{p, \text{with $q$ odd}}
q \\
 = & \   \frac{1}{4(n^2 + n)} \sum_{j=1}^{n} (2j+1)\\
 = &  \ \frac{n^2 +2n}{4(n^2 + n)} \\
= & \ \frac{3}{10} - \frac{(n-4)}{20(n+1)} \\
 \le & \  \frac{3}{10}. \end{aligned}$$
In reality, $f(p) \rightarrow 0$, since 
$$f(p) \le \frac{1}{p^2} \sum_{q \le p} q
\le \frac{1}{p^2} \sum_{q \le p} p
=  \frac{1}{p^2} \cdot p \pi(p) \sim 1/\log p.$$
</s>