ArticleslgStudy

computer science

Euler's factorization method

Euler's factorization method is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Euler's factorization method rather than just read about it. In short: Euler's factorization method is a technique for factoring a number by writing it as a sum of two squares in two different ways. For example the number 1000009 can be written as 10002+32 or as 9722+2352 and Euler's method gives the factorization 1000009=293⋅3413.

Key takeaways

  • Euler's factorization method belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Euler's factorization method to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Euler's factorization method from memory before moving on to harder problems.

Reference excerpt

Euler's factorization method is a technique for factoring a number by writing it as a sum of two squares in two different ways. For example the number 1000009 can be written as 10002+32 or as 9722+2352 and Euler's method gives the factorization 1000009=293⋅3413. The idea that two distinct representations of an odd positive integer may lead to a factorization was apparently first proposed by Marin Mersenne. However, it was not put to use extensively until one hundred years later by Euler. His most celebrated use of the method that now bears his name was to factor the number 1000009, which apparently was previously thought to be prime even though it is not a pseudoprime by any major primality test. Euler's factorization method is more effective than Fermat's for integers whose factors are not close together and potentially much more efficient than trial division if one can find representations of numbers as sums of two squares reasonably easily. The methods used to find representations of numbers as sums of two squares are essentially the same as with finding differences of squares in Fermat's factorization method.

Disadvantage and limitation The great disadvantage of Euler's factorization method is that it cannot be applied to factoring an integer with any prime factor of the form 4k + 3 occurring to an odd power in its prime factorization, as such a number can never be the sum of two squares. Even odd composite numbers of the form 4k + 1 are often the product of two primes of the form 4k + 3 (e.g. 3053 = 43 × 71) and again cannot be factored by Euler's method. This restricted applicability has made Euler's factorization method disfavoured for computer factoring algorithms, since any user attempting to factor a random integer is unlikely to know whether Euler's method can actually be applied to the integer in question. It is only relatively recently that there have been attempts to develop Euler's method into computer algorithms for use on specialised numbers where it is known Euler's method can be applied.

Theoretical basis The Brahmagupta–Fibonacci identity states that the product of two sums of two squares is a sum of two squares. Euler's method relies on this theorem but it can be viewed as the converse, given n=a2+b2=c2+d2 we find n as a product of sums of two squares. First deduce that

a2−c2=d2−b2 and factor both sides to get

(a−c)(a+c)=(d−b)(d+b) (1) Now let k=gcd⁡(a−c,d−b) and h=gcd⁡(a+c,d+b) so that there exists some constants l,m,l′,m′ satisfying

(a−c)=kl, (d−b)=km, gcd⁡(l,m)=1

(a+c)=hm′, (d+b)=hl′, gcd⁡(l′,m′)=1 Substituting these into equation (1) gives

klhm′=kmhl′ Canceling common factors yields

lm′=l′m Now using the fact that (l,m) and (l′,m′) are pairs of relatively prime numbers, we find that

l=l′ m=m′ So

(a−c)=kl (d−b)=km (a+c)=hm (d+b)=hl We now see that m=gcd⁡(a+c,d−b) and l=gcd⁡(a−c,d+b) Applying the Brahmagupta–Fibonacci identity we get

(k2+h2)(l2+m2)=(kl+hm)2+(km−hl)2=((a−c)+(a+c))2+((d−b)−(d+b))2=(2a)2+(2b)2=4n. As each factor is a sum of two squares, one of these must contain both even numbers: either (k,h) or (l,m). Without loss of generality, assume that pair (k,h) is even. The factorization then becomes

n=((k2)2+(h2)2)(l2+m2).

Worked example Since: 1000009=10002+32=9722+2352 we have from the formula above:

Thus,

1000009=[(42)2+(342)2]⋅[(142)2+(1162)2] =(22+172)⋅(72+582) =(4+289)⋅(49+3364) =293⋅3413

Pseudocode function Euler_factorize(int n) -> list[int] if is_prime(n) then print("Number is not factorable") exit function for-loop from a=1 to a=ceiling(sqrt(n)) b2 = n - a*a b = floor(sqrt(b2)) if b*b==b2 break loop preserving a,b if a*a+b*b!=n then print("Failed to find any expression for n as sum of squares") exit function for-loop from c=a+1 to c=ceiling(sqrt(n)) d2 = n - c*c d = floor(sqrt(d2)) if d*d==d2 then break loop preserving c,d if c*c+d*d!=n then print("Failed to find a second expression for n as sum of squares") exit function A = c-a, B = c+a C = b-d, D = b+d k = GCD(A,C)//2, h = GCD(B,D)//2 l = GCD(A,D)//2, m = GCD(B,C)//2 factor1 = k*k + h*h factor2 = l*l + m*m return list[ factor1, factor2 ]

References Ore, Oystein (1988). "Euler's Factorization Method". Number Theory and Its History. Courier Corporation. pp. 59–64. ISBN 978-0-486-65620-5. McKee, James (1996). "Turning Euler's Factoring Method into a Factoring Algorithm". Bulletin of the London Mathematical Society. 4 (28): 351–355. doi:10.1112/blms/28.4.351.

Worked examples

Example 1 — a first encounter with Euler's factorization method

Start with the simplest possible case. Write down what Euler's factorization method claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Euler's factorization method before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Euler's factorization method ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Euler's factorization method

In research
Euler's factorization method appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Euler's factorization method in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Euler's factorization method is common in secondary-school and first-year university syllabi. It links to neighbouring topics Integer factorization algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Euler's factorization method outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Euler's factorization method” →

How to study Euler's factorization method in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Euler's factorization method means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Euler's factorization method out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Euler's factorization method in simple terms?

Euler's factorization method is a technique for factoring a number by writing it as a sum of two squares in two different ways. For example the number 1000009 can be written as 10002+32 or as 9722+2352 and Euler's method gives the factorization 1000009=293⋅3413.

Why does Euler's factorization method matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Euler's factorization method?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Euler's factorization method.

Tags

  • Integer factorization algorithms

Keep exploring