Let $p_n$ be the $n$th prime number and all variables, unless otherwise specified, are natural numbers.
Conjecture: For all square-free $n \geq 2$, the following function evaluates to a positive integer: $$F(n) = -1 + \sum_{d \mid n} \mu(d) \sum_{a^2 = 1\mod d, \ \\ 0 \leq a \lt d}\left\lfloor\frac{\frac{12}{5} p_{\text{max}}(n)-a}{d} \right\rfloor$$ where $p_{\text{max}}(n)$ is the maximum prime divisor of $n$. And this conjecture is tight with respect to the constant $C = \frac{12}{5}$. Any deviation to a lower value will yield a false conjecture.
Verification Code:
from sympy import *
N = 5000
epsilon = 0.00000000 # Try setting to 0.000000001
for n in range(2, N):
if all(j == 1 for j in factorint(n).values()): # n is square-free
m = ((12 / 5) - epsilon)* max(primefactors(n))
S = -1
for d in divisors(n):
for a in range(0, d):
if (a ** 2 - 1) % d == 0:
S += (-1) ** primeomega(d) * floor((m - a)/d)
assert S > 0
print(m,n, S)
What is interesting is that $\{ \bar{a} \in \Bbb{Z}/d : a^2 = 1\mod d\} \leqslant (\Bbb{Z}/d)^{\times}$ is a subgroup of the units modulo $d$ and you can't change that either unless you adjust $C$.
Anyway, was wanting some information about sums of this type. There's not much data on the web that I could find about strictly sums over divisors of square-free integers. When you remove the square-free requirement, the summation goes chaotic, i.e. takes on negative or positive values. Are there any good papers out there about this?
Attempt. This doesn't attempt to answer the question but instead partially prove the result for when $n = q$ is a prime number. Let $[z]_q =$ the usual (least, non-negative) residue of $z$ modulo $q$, for any $z \in \Bbb{Q}$.
$$\begin{align} F(q) &= -1 + \sum_{d \in \{1,q\}}\mu(d) \sum_{a^2 = 1 \pmod d} \lfloor\frac{\frac{12}{5} q - a}{d} \rfloor \\ &= -1 + \frac{12}{5}q - \lfloor\frac{\frac{12}{5} q - 1}{q} \rfloor - \lfloor\frac{\frac{12}{5} q - (q-1)}{q} \rfloor \\ &= -1 + \frac{12}{5}q - \frac{\frac{12}{5}q - 1 - [\frac{12}{5}q - 1]_q}{q} - \frac{\frac{12}{5}q - (q-1) - [\frac{12}{5}q - (q-1)]_q}{q} \\ &= -1 + \frac{12}{5} q - \frac{12}{5} +\frac{1}{q} +\frac{[\frac{12}{5}q - 1]_q}{q} -\frac{12}{5} +1 -\frac{1}{q} + \frac{[\frac{12}{5}q + 1]_q}{q} \\ &= \frac{12}{5}q - \frac{24}{5} + \frac{[\frac{12}{5} q - 1]_q}{q} + \frac{[\frac{12}{5} q + 1]_q}{q} \end{align}$$
Now plug in $q = 2$. We have:
$$ \frac{24}{5} - \frac{24}{5} + \text{ two numbers that can't both be zero} \gt 0 $$
since the function can only (clearly) take on integer values, we have that $F(2) \geq 1$. By induction, for larger primes, the value is clearly also $\geq 1$. $\blacksquare$
What remains to be proven is that it's true for $F(n)$ with $\Omega(n) \gt 1$, $n$ square-free.