The greatest common divisor ( GCD ) of two integers a and b is usually calculated with the ( well-known ) Euclidean Algorithm. There is however an alternative algorithm which is based on an entirely different idea. Let's illustrate this idea with an example. Let a, b be integers, a >:b and (a, b) = GCD(a,b). Then the following rules can be applied recursively until a=b=GCD(a,b):
If ( a=even AND b=even) then GCD(a,b)=2*GCD(a/2,b/2)
If ( a=odd AND b=even) then GCD(a,b)=GCD(a,b/2)
If ( a=even AND b=odd) then GCD(a,b)=GCD(a/2,b)
If ( a=odd AND b=odd) then GCD(a,b)=GCD(a-b,b)
Example
(36, 27) = (27, 36/2)
(27, 18) = (27, 18/2)
(27, 9) = (27-9, 9)
(18, 9) = (18/2, 9)
(9, 9) Halt.
GCD(36,27)=9.
Compare using the Euclidean Algorithm
36 = 1 * 27 + 9
27 = 3 * 9 + 0 Halt.
GCD(36,27)=9.
However, this doesn't mean that the Euclidean Algorithm is always faster.
Please follow this blog
Search this blog
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Among lectures on Calculus I,II and III, ( Introduction to ) Linear Algebra and ( Introduction to ) Differential Equations from the UCCS ( ...
-
Problem: We want to calculate the sum of the elements of a list of numbers. Suppose this list is named l and has been assigned the value {1,...
-
Today I started to read the Ramanujan biography ( The e-book version, of course. ) The book looks promising. What was it like to communicate...
-
I found a set of video lectures on Abstract Algebra. MATH E-222 Abstract Algebra - http://www.extension.harvard.edu/openlearning/math222/ E...
-
Ramanujan's genius (r) was discovered by Hardy (l) At a very young age Ramanujan designed the following formula for a 3 by 3 magic sq...
Welcome to The Bridge
Mathematics: is it the fabric of MEST?
This is my voyage
My continuous mission
To uncover hidden structures
To create new theorems and proofs
To boldly go where no man has gone before

(Raumpatrouille – Die phantastischen Abenteuer des Raumschiffes Orion, colloquially aka Raumpatrouille Orion was the first German science fiction television series. Its seven episodes were broadcast by ARD beginning September 17, 1966. The series has since acquired cult status in Germany. Broadcast six years before Star Trek first aired in West Germany (in 1972), it became a huge success.)
This comment has been removed by a blog administrator.
ReplyDelete