I was writing a computer program and I found that for all sequences that I tested the number of $x$ in a sequence of $30a$ consecutive integers for a prime $p$ is less than or equal to: $$2\left\lceil\frac{3a}{p}\right\rceil$$
I've been trying to check if this is always true but can only establish that the number of $x$ is less than or equal to:
$$6\left\lfloor\frac{a}{p}\right\rfloor + \min(a - p\left\lfloor\frac{a}{p}\right\rfloor, 6)$$
Here's my reasoning for my estimate:
It is easy to count the number of integers $x$ in a sequence of $30a$ consecutive integers where $\gcd(x(x+2),30)=1$.
There are $3a$ such integers based on the reduced residue system modulo $30 = \left\{1, 7, 11, 13, 17, 19, 23, 29\right\}$
It is also easy to come up with a simple estimate. In a sequence of $30p$ consecutive integers, there are at most $6$ where $p \mid x(x+2)$ and $\gcd(x(x+2),30)=1$.
Let $a = qp + r$ where $r < p$
In this case, the upper bound $6q + \min(r,6)$
Can you show that $2\lceil\frac{3a}{p}\rceil$ is a valid upper bound, provide a counter example, show that it is not always a valid upper bound, or make a suggestion on the approach I can do to verify the upper bound?
The sequence $45, 46, \dots, 163, 164$ provides a counterexample for $a = 4$ and $p = 7$. Indeed, the conditions $\gcd(x(x+2),30) = 1$ and $7 \mid x(x+2)$ are satisfied for $x = 47, 77, 89, 119, 131, 161$, but $2\lceil 3a/p \rceil = 4 < 6$.
Here is a way to obtain both a lower bound and an upper bound. Observe that $x$ satisfies $\gcd(x(x+2),30) = 1$ and $p \mid x(x+2)$ if and only if it is the solution of a system of the form \begin{align*} x &\equiv b \pmod{30} \\ x &\equiv c \pmod{p} \end{align*} where $b \in \{ 11,17,29 \}$ and $c \in \{ 0,-2 \}$. By the Chinese remainder theorem, such a system has a solution which is unique modulo $30p$. Since there are $6$ possible choices for the pair $(b,c)$, this implies that every sequence of $30p$ consecutive integers contains exactly $6$ integers $x$ with $\gcd(x(x+2),30) = 1$ and $p \mid x(x+2)$. Therefore, the number $N$ of such integers in a sequence of $30a$ consecutive integers satisfies $$ 6\left\lfloor \frac{a}{p} \right\rfloor \le N \le 6\left\lfloor \frac{a}{p} \right\rfloor + 6 $$