RU beehive logo ITEC dept promo banner
ITEC 122
2008fall
ibarland

homeinfolecturesexamsarchive

lect11b
implementing ints
two's complement

gcd

Greatest Common Divisor, or 'gcd'.

gcd(900,1026):
  Imagine you want to make two buildings 900' tall and 1026' tall.
  What is the tallest measuring-stick which can measure
  both buildings, *and* not have any fractional part left over?

For example, a three-foot rod would evenly measure both 900' and 1026'
  (300x and 342x, resp).
  But you know, a 6' rod would work too (150x and 171x, resp.).
  But is 6' the *tallest* such rod?  (It turns out: No!)

  (Or, instead of measuring rods, suppose you are using brick-heights:
  You want to use the same height brick on both buildings (to save cost),
  and you want to use as tall a brick as possible (to save work).)

Well, *whatever* size measure rod we use, if it evenly divides 900 and 1026,
it must also evenly divide the difference, 1026-900=126.

   In fact, gcd(1026,900)=gcd(90,36).
      (That's true of *any* divisor, not just the gcd)

   gcd(1026,900)        We can subtract off a copy of the smaller building,
 = gcd(900,1026-900)    and the gcd must still divide the difference evenly.(*)
 = gcd(900,126)         (do the
 = gcd(126, 900-7*126)  Take off 7 copies of of the smaller building
 = gcd(18,
  

(*) It's clear that any divisor of 1026 and 900 must be a divisor of their
difference; showing that the *greatest* common divisor of each is the
same takes a smidgen of work.  (Try a proof-by-contradiction.)

repeated squaring




Motivate public-key encryption

Induction: intro

homeinfolecturesexamsarchive


©2008, Ian Barland, Radford University
Last modified 2008.Dec.12 (Fri)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme