- #1

- 205

- 2

Do they use the Euclidean Algorithm?

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- I
- Thread starter matqkks
- Start date

- #1

- 205

- 2

Do they use the Euclidean Algorithm?

- #2

mathman

Science Advisor

- 8,046

- 535

- #3

jedishrfu

Mentor

- 13,578

- 7,566

- #4

jedishrfu

Mentor

- 13,578

- 7,566

https://en.m.wikipedia.org/wiki/Euclidean_algorithm

I imagine math software would use this algorithm to compute it as subtractions are relatively cheap compared to multiplications or divisions.

Another remote possibility is it uses a combination of lookup table and Euclidean algorithm to speed things up although that may take up more memory than necessary and depending on the table size more costly time wise.

- #5

mfb

Mentor

- 35,916

- 12,743

You still need some sort of division to calculate how much you have to subtract. Simply subtracting the smaller number from the larger number repeatedly has a really bad worst-case runtime if the numbers are very different (exponential, while divisions make the method scale with the input length squared).I imagine math software would use this algorithm to compute it as subtractions are relatively cheap compared to multiplications or divisions.

There are alternative algorithms that can compute the GCD faster than quadratic runtime for longer inputs.

Share:

- Replies
- 13

- Views
- 440