encyclopegia.org

Cornacchia's algorithm

In computational number theory, Cornacchia's algorithm is an algorithm for solving the Diophantine equation x^2+dy^2=m , where 1\le d and d and m are coprime. The algorithm was described in 1908 by Giuseppe Cornacchia.

In computational number theory, Cornacchia's algorithm is an algorithm for solving the Diophantine equation x^2+dy^2=m , where 1\le d and d and m are coprime. The algorithm was described in 1908 by Giuseppe Cornacchia. ==The algorithm== First, one finds any solution to r_0^2\equiv-d\pmod m ; if no such r_0 exist, there can be no primitive solution to the original equation. Without loss of generality, one can assume that (if not, then replace with , which will still be a root of ). Then the Euclidean algorithm can be employed to find r_1\equiv m\pmod{r_0} , r_2\equiv r_0\pmod{r_1} and so on; stopping when r_k . If s=\sqrt{\tfrac{m-r_k^2}d} is an integer, then the solution is x=r_k,y=s ; otherwise try another root of until either a solution is found or all roots have been exhausted. In this case there is no primitive solution. This algorithm can also be used to find non-primitive solutions where , because the existence of such a solution implies that divides (and equivalently, that if is square-free, then all solutions are primitive). Thus the above algorithm can be used to search for a primitive solution to . If such a solution is found, then will be a solution to the original equation. ==Example== Solve the equation x^2+6y^2=103 . A square root of −6 (mod 103) is 32, and 103 ≡ 7 (mod 32); since 7^2 and \sqrt{\tfrac{103-7^2}6}=3 , there is a solution x = 7, y = 3. ==References== ==External links==

References

No reference rows published for this article.

Cite this article

MLA

"Cornacchia's algorithm." encyclopegia.org, 2026, https://encyclopegia.org/wiki/cornacchia-s-algorithm. Accessed 24 November 2026.

Chicago

"Cornacchia's algorithm." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/cornacchia-s-algorithm.

APA

encyclopegia.org. (2026). Cornacchia's algorithm. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/cornacchia-s-algorithm

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

μ-law algorithm

stub · references available

bitap algorithm

stub · references available

QR algorithm

stub · references available

Prim's algorithm

stub · references available

greedy algorithm

stub · references available

Apriori algorithm

stub · references available

Baum–Welch algorithm

stub · references available

Glushkov's construction algorithm

stub · references available
CC BY-SA 4.0 · tier1-factual · https://en.wikipedia.org/w/index.php?oldid=1356361442 · 0.55 · snapshot cornacchia-s-algorithm-589204-1d89a52c8f52e8e4 · QID Q5171072

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.