Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Euclidean algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Worst-case ==== If the Euclidean algorithm requires ''N'' steps for a pair of natural numbers ''a'' > ''b'' > 0, the smallest values of ''a'' and ''b'' for which this is true are the [[Fibonacci number]]s ''F''<sub>''N''+2</sub> and ''F''<sub>''N''+1</sub>, respectively.<ref name="Knuth, p. 343">{{harvnb|Knuth|1997}}, p. 343</ref> More precisely, if the Euclidean algorithm requires ''N'' steps for the pair ''a'' > ''b'', then one has ''a'' β₯ ''F''<sub>''N''+2</sub> and ''b'' β₯ ''F''<sub>''N''+1</sub>. This can be shown by [[mathematical induction|induction]].<ref>{{Harvnb|Mollin|2008|p=21}}</ref> If ''N'' = 1, ''b'' divides ''a'' with no remainder; the smallest natural numbers for which this is true is ''b'' = 1 and ''a'' = 2, which are ''F''<sub>2</sub> and ''F''<sub>3</sub>, respectively. Now assume that the result holds for all values of ''N'' up to ''M'' β 1. The first step of the ''M''-step algorithm is ''a'' = ''q''<sub>0</sub>''b'' + ''r''<sub>0</sub>, and the Euclidean algorithm requires ''M'' β 1 steps for the pair ''b'' > ''r''<sub>0</sub>. By induction hypothesis, one has ''b'' β₯ ''F''<sub>''M''+1</sub> and ''r''<sub>0</sub> β₯ ''F''<sub>''M''</sub>. Therefore, ''a'' = ''q''<sub>0</sub>''b'' + ''r''<sub>0</sub> β₯ ''b'' + ''r''<sub>0</sub> β₯ ''F''<sub>''M''+1</sub> + ''F''<sub>''M''</sub> = ''F''<sub>''M''+2</sub>, which is the desired inequality. This proof, published by [[Gabriel LamΓ©]] in 1844, represents the beginning of [[computational complexity theory]],<ref>{{Harvnb|LeVeque|1996|p=35}}</ref> and also the first practical application of the Fibonacci numbers.<ref name="Knuth, p. 343"/> This result suffices to show that the number of steps in Euclid's algorithm can never be more than five times the number of its digits (base 10).<ref>{{Harvnb|Mollin|2008|pp=21β22}}</ref> For if the algorithm requires ''N'' steps, then ''b'' is greater than or equal to ''F''<sub>''N''+1</sub> which in turn is greater than or equal to ''Ο''<sup>''N''β1</sup>, where ''Ο'' is the [[golden ratio]]. Since ''b'' β₯ ''Ο''<sup>''N''β1</sup>, then ''N'' β 1 β€ log<sub>''Ο''</sub>''b''. Since log<sub>10</sub>''Ο'' > 1/5, (''N'' β 1)/5 < log<sub>10</sub>''Ο'' log<sub>''Ο''</sub>''b'' = log<sub>10</sub>''b''. Thus, ''N'' β€ 5 log<sub>10</sub>''b''. Thus, the Euclidean algorithm always needs less than [[Big O notation|''O''(''h'')]] divisions, where ''h'' is the number of digits in the smaller number ''b''.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)