I have been working for quite a while on finding a closed formula for the Legendre Symbol. Inspite of my best efforts I can't come anything better with a formula for the symbol $\left(\dfrac{q}{p}\right)$ of the form $$f(q,p)+\displaystyle\sum_{k=1}^{\frac{p-1}{2}}\left \lfloor \dfrac{kq}{p}\right \rfloor-\left \lfloor \dfrac{k(q-1)}{(p-1)}\right \rfloor$$$$f(q,p)+\displaystyle\sum_{k=1}^{\frac{p-1}{2}}\left(\left \lfloor \dfrac{kq}{p}\right \rfloor-\left \lfloor \dfrac{k(q-1)}{(p-1)}\right \rfloor\right)$$ For two odd primes $p$ and $q$ with $p>q$. The term $f(p,q)$ has a closed form but I can't find a closed form for the second expression. I have searched in the internet for getting any clue as to how to determine the closed form for this function but the only thing that I found was that $\displaystyle\sum_{k=1}^{\frac{p-1}{2}}\left \lfloor \dfrac{kq}{p}\right \rfloor$ in general has no closed form. But it may be the case that the sums individually may have no closed form (though the second sum has a closed form) but the difference has.
Also, not the explicit sum but comments regarding its parity will be enough.
Notice that the sum can be easily obtained if we can find a closed form for the number of points on the boundary lines or within a triangle with vertices $(0,0)$,$\left(\frac{p-1}{2},\frac{q-1}{2} \right)$ and $\left(\frac{p-1}{2},\frac{q(p-1)}{2p} \right)$.
So, is there any method of obtaining a closed formula for the sum? If not, then can some references be given which inspects this kind of sums? Any help will be appreciated.