An O(M(n) logn) Algorithm for the Jacobi Symbol

  • Richard P. Brent
  • Paul Zimmermann
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6197)


The best known algorithm to compute the Jacobi symbol of two n-bit integers runs in time O(M(n)logn), using Schönhage’s fast continued fraction algorithm combined with an identity due to Gauss. We give a different O(M(n)logn) algorithm based on the binary recursive gcd algorithm of Stehlé and Zimmermann. Our implementation — which to our knowledge is the first to run in time O(M(n)logn) — is faster than GMP’s quadratic implementation for inputs larger than about 10000 decimal digits.


Decimal Digit Binary Division Jacobi Symbol Good Iteration Quadratic Algorithm 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Bach, E.: A note on square roots in finite fields. IEEE Trans. on Information Theory 36(6), 1494–1498 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Bach, E., Shallit, J.O.: Algorithmic Number Theory: Efficient Algorithms, vol. 1. MIT Press, Cambridge (1996) (Solution to problem 5.52)zbMATHGoogle Scholar
  3. 3.
    Bachmann, P.: Niedere Zahlentheorie, Teubner, Leipzig, vol. 1 (1902); Reprinted by Chelsea, New York (1968)Google Scholar
  4. 4.
    Brent, R.P.: Twenty years’ analysis of the binary Euclidean algorithm. In: Davies, J., Roscoe, A.W., Woodcock, J. (eds.) Millennial Perspectives in Computer Science: Proceedings of the 1999 Oxford - Microsoft Symposium in honour of Professor Sir Antony Hoare, Palgrave, New York, pp. 41–53 (2000),
  5. 5.
    Daireaux, B., Maume-Deschamps, V., Vallée, B.: The Lyapunov tortoise and the dyadic hare. In: Proceedings of the 2005 International Conference on Analysis of Algorithms, DMTCS Proc. AD, pp. 71–94 (2005),
  6. 6.
    Gauss, C.F.: Theorematis fundamentalis in doctrina de residuis quadraticis, demonstrationes et ampliatones novæ. Comm. Soc. Reg. Sci. Gottingensis Rec. 4 (presented February 10, 1817) (1818); Reprinted in Carl Friedrich Gauss Werke, Bd. 2: Höhere Arithmetik, Göttingen, pp. 47–64 (1876) Google Scholar
  7. 7.
    Knuth, D.E.: The Art of Computer Programming. In: Seminumerical Algorithms, 3rd edn., vol. 2, Addison-Wesley, Reading (1997)Google Scholar
  8. 8.
    Möller, N.: On Schönhage’s algorithm and subquadratic integer GCD computation. Mathematics of Computation 77(261), 589–607 (2008)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Schönhage, A.: Schnelle Berechnung von Kettenbruchentwicklungen. Acta Informatica 1, 139–144 (1971)zbMATHCrossRefGoogle Scholar
  10. 10.
    Schönhage, A.: Personal communication by email (December 2009)Google Scholar
  11. 11.
    Schönhage, A., Grotefeld, A.F.W., Vetter, E.: Fast Algorithms: A Multitape Turing Machine Implementation. BI-Wissenschaftsverlag, Mannheim (1994)zbMATHGoogle Scholar
  12. 12.
    Shallit, J., Sorenson, J.: A binary algorithm for the Jacobi symbol. ACM SIGSAM Bulletin 27(1), 4–11 (1993), CrossRefGoogle Scholar
  13. 13.
    Stehlé, D., Zimmermann, P.: A binary recursive gcd algorithm. In: Buell, D.A. (ed.) ANTS 2004. LNCS, vol. 3076, pp. 411–425. Springer, Heidelberg (2004)Google Scholar
  14. 14.
    Vallée, B.: A unifying framework for the analysis of a class of Euclidean algorithms. In: Gonnet, G.H., Viola, A. (eds.) LATIN 2000. LNCS, vol. 1776, pp. 343–354. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  15. 15.
    Weilert, A.: Fast Computation of the Biquadratic Residue Symbol. Journal of Number Theory 96, 133–151 (2002)zbMATHMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Richard P. Brent
    • 1
  • Paul Zimmermann
    • 2
  1. 1.Australian National UniversityCanberraAustralia
  2. 2.INRIA Nancy - Grand EstVillers-lès-NancyFrance

Personalised recommendations