The Legendre symbol may be evaluated systematically by means of the following
algorithm, though commonly the attentive calculator will find many short cuts.
First reduce b modulo p, so that we may assume 0 < b < p; then factor b as a product
of primes and use the total multiplicativity of the Legendre symbol