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(\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. 



Solution or Reference Request for a Closed Form of the Sum
I am not sure what you mean by "closed formula", but I provide below an identity that might satisfy you. It is a consequence of Gauss's lemma and it implies quadratic reciprocity (for details see Theorems 26 to 29 [here](http://www.renyi.hu/~gharcos/notes_m328k.pdf)).


**Theorem.** For $a>0$ and $(p,2a)=1$ we have 
$$\left(\frac{a}{p}\right)=(-1)^{s},\quad\text{where}\quad s:=\sum\_{1\leq m\leq a/2}
\left(\left\lfloor\frac{mp}{a}\right\rfloor-
\left\lfloor\frac{mp}{a}-\frac{p}{2a}\right\rfloor\right).$$ 


