Calculate the Kronecker symbol
Python 3, 747 369 335 bytes

As an example answer, only slightly golfed, and to give you an idea of what an answer will look like.
And yes, the prime factorization and run-length-encoding bits are cribbed from Pyth with apologies to isaacg.
from itertools import*
def k(d,r):
 if d&lt;0:a=-d;m=1
 else:a=d;m=0
 if r==1:return 1
 p=1;w=r;n=2;f=[]
 while n*n&lt;=w:
  while w%n&lt;1:w//=n;f+=n,
  n+=1
 if w&gt;1:f+=w,
 z=[[k,len(list(g))]for k,g in groupby(f)]
 for i,j in z:
  if i==2:p*=pow(-1,(a*a-1)//8)
  x=pow(a,(i-1)//2,i)
  if x&gt;1:x-=i
  p*=x**j
 if m:p*=pow(-1,(r-1)//2)
 return p