Define the family of functions for $n \geq 1$.
$$ f_n(x) = \sum_{d \mid p_n\#}(-1)^{\omega(d)}\sum_{0 \leq r \lt d \\ r^2 = 1 \pmod d}\left\lfloor \frac{x - r}{d}\right\rfloor $$
Conjecture. In general (and this distinguishes it from my other post), for every $n \geq 1$ the function $f_n : \Bbb{R} \to \Bbb{Z}$ is a non-decreasing function.
Proof Attempt.
$$ f(x+1) = \\ \sum_{d \mid p_n\#}(-1)^{\omega(d)}\sum_{0\leq r\lt d \\ r^2 = 1\pmod d}\lfloor\frac{x - r}{d} \rfloor \ \ + \sum_{d \mid \gcd(p_n\#, (x +1)^2 -1)} (-1)^{\omega(d)}\sum_{0\leq r \lt d \\ x +1-r = 0\pmod d \\ r^2 = 1\pmod d}1 \\ = f(x) + A $$
But $x + 1 = r$ can only be true for either no root modulo $d$ or at most one square root of $1$ modulo $d$. Therefore this becomes:
$$ f(x+1) = f(x) + A = \\ \sum_{d \mid p_n\#}(-1)^{\omega(d)}\sum_{0\leq r\lt d \\ r^2 = 1\pmod d}\lfloor\frac{x - r}{d} \rfloor + \sum_{d \mid \gcd(p_n\#, (x +1)^2 -1)} (-1)^{\omega(d)} 1 = f(x) $$
Lemma. The summation term $A$ on the right is either $0$ or $1$.
Proof. If $\gcd(p_n\#, (x + 1)^2 - 1) = 1$ then it is definitely $1$ by computing it. But if $\gcd(p_n\#, (x+1)^2 -1) = e$ then the $\pm 1$'s cancel because there are $\sigma_0(e) = 2^{\omega(e)}$ divisors $d$ of $e$. The ones for which $\omega(d)$ is even can be paired with the ones for which $\omega(d)$ is odd in a 1-1 correspondence. For example suppose that $e = p$ a single prime, then the summation term's value becomes: $1 - 1 = 0$. Now suppose $e = pq$ then we have the divisors as $\{1,p,q,pq\}$. There are exactly two divisors $d$ for which $\omega(d)$ is even and exactly two for which $\omega(d)$ is odd, so the summation term's value is $0$. And so on, by induction / exercise for the reader. $\blacksquare$.
Does this proof sketch work in your analysis of it?
https://math.stackexchange.com/a/4772865/26327
I recommended, since that answer is more appropriate here that they split their answer up and make a post here for the general case.
– Daniel Donnelly Sep 21 '23 at 15:26