Christoph Bergemann's "Calculating the Jacobi Symbol"

Read this page.