division and gcd n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Division and GCD PowerPoint Presentation
Download Presentation
Division and GCD

Loading in 2 Seconds...

play fullscreen
1 / 26

Division and GCD - PowerPoint PPT Presentation


  • 88 Views
  • Uploaded on

Division and GCD. CSC2110 Tutorial 7 Darek Yung. Outline. Self Introduction Announcement Quick Review Example Q & A. Self Introduction. Yung Chun Kong, Darek Responsible for Topics in Number Theory Tutorial 7 – 9 The third class work Office: SHB 115

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Division and GCD' - zinnia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
division and gcd

Division and GCD

CSC2110 Tutorial 7

Darek Yung

outline
Outline
  • Self Introduction
  • Announcement
  • Quick Review
  • Example
  • Q & A
self introduction
Self Introduction
  • Yung Chun Kong, Darek
  • Responsible for
    • Topics in Number Theory
    • Tutorial 7 – 9
    • The third class work
  • Office: SHB 115
  • Office hour: Wed – Fri, 3pm – 7pm
  • Feel free to raise question in newsgroup
announcement
Announcement
  • You can collect your class work 1 from Tom (SHB 115)
quick review
Quick Review
  • Divisibility
  • Division Theorem
  • GCD
  • (Extended) Euclid’s GCD Algorithm
  • Linear Combination
  • Die Hard
divisibility
Divisibility
  • If a | b, then a | bc for all c.
  • If a | b and b | c, then a | c.
  • If a | b and a | c, then a | sb + tc for all s and t.
  • For all c ≠ 0, a | b if and only if ca | cb.
division theorem
Division Theorem
  • a = qb + r, 0  r < b
  • q, r are unique
slide8
GCD
  • Every common divisor of a and b divides GCD(a, b)
  • GCD(ka, kb) = k * gcd(a,b) for all natural number k
  • If GCD(a, b) = GCD(a, c) = 1, GCD(a, bc) = 1
  • If a | bc and GCD(a, b) = 1, a | c
  • GCD(a, b) = GCD(b, rem(a, b))
extended euclid s gcd algorithm
(Extended) Euclid’s GCD Algorithm
  • By Division Theorem
    • a = qb + r
  • And GCD property
    • GCD(a, b) = GCD(b, rem(a, b))
  • We will have examples later
linear combination
Linear Combination
  • sa + tb is a linear combination of a and b
  • Smallest positive linear combination, SPC
  • SPC(a, b) = GCD(a, b)
die hard
Die Hard
  • Goal: want to z gallon of water by using jugs with x and y gallon capacities
  • Solved by SPC = GCD, i.e. EE GCD Algorithm
example
Example
  • True / False
    • Q1: False, e.g. when x is multiple of p
    • Q2: False, e.g. when y is multiple of x
    • Q3: True, definition of prime
example1
Example
  • True / False
    • Q4: False, e.g. when s = t = 1
    • Q5: False, e.g. when m = 2, a = 4, s=t=b=1
    • Q6: False, the smallest POSITIVE one
example2
Example
  • True / False
    • Q7: True, consider: ka + kb = k(a+b)
    • Q8: False, should be “divides”
      • e.g. GCD(12,18) = 6, 2 | 6
    • Q9: True, implies GCD(a, b) = GCD(a, c) = 1
    • Q10: True, GCD(a, bc) >= GCD(a, c)
example3
Example
  • True / False
    • Q11: False, when z is multiple of GCD(x, y)
    • Q12: False, e.g. consider z = x // z = GCD(x, y)
example4
Example
  • True / False
    • Q13: False,

e.g. when z is not multiple of x, y = xz

    • Q14: False, e.g. when y is multiple of x, z is not
    • Q15: True,
      • always able to find x, s.t. GCD(x,y)=1 when y is given
example5
Example
  • Find GCD(564, 978)
    • 978 = 1(564) + 414
    • 564 = 1(414) + 150
    • 414 = 2(150) + 114
    • 150 = 1(114) + 36
    • 114 = 3(36) + 6
    • 36 = 6(6) + 0
    • GCD(564, 978) = 6
    • Euclid’s GCD Algorithm

Caution: No mark will be given if steps are skipped!!!

(Marks for steps will be given even if answer is wrong)

example6
Example
  • Find SPC(364, 516) and values of s, t that

364s + 516t = SPC(364, 516)

example7
Example
  • Find SPC(364, 516)
    • SPC(364, 516) = GCD(364, 516)
    • 516 = 1(364) + 152
    • 364 = 2(152) + 60
    • 152 = 2(60) + 32
    • 60 = 1(32) + 28
    • 32 = 1(28) +4
    • 28 = 7(4) + 0
    • SPC(364, 516) = GCD(364, 516) = 4

How to find s and t???

example8
Example
  • 516 = 1(364) + 152
    • 152 = 516 – 1(364)
  • 364 = 2(152) + 60
    • 60 = 364 – 2(152) = -2(516) + 3(364)
  • 152 = 2(60) + 32
    • 32 = 152 – 2(60) = 5(516) – 7(364)
  • 60 = 1(32) + 28
    • 28 = 60 – 1(32) = -7(516) + 10(364)
  • 32 = 1(28) +4
    • 4 = 32 – 1(28) = 12(516) – 17(364)
  • 28 = 7(4) + 0
  •  s = -17, t = 12
  •  Extended Euclid’s GCD Algorithm
example9
Example
  • Find SPC(152, 376) and values of s, t that

152s + 376t = SPC(152, 376)

example10
Example
  • SPC(152, 376) = GCD(152, 376)
  • 376 = 2(152) + 72
    • 72 = 376 – 2(152)
  • 152 = 2(72) + 8
    • 8 = 152 – 2(72) = -2(376) + 5(152)
  • 72 = 9(8) + 0
  • SPC(152, 376) = 8, with s = 5, t = -2
example11
Example
  • Find GCD(42, 56, 98)
    • GCD(42, 56, 98) = GCD(42, GCD(56, 98))
    • GCD(56, 98) = 14 (by Euclid’s GCD Algorithm)
    • GCD(40, 14) = 2 (by Euclid’s GCD Algorithm)

 GCD(42, 56, 98) = 2

example12
Example
  • Show how to get 81 gallons of water by using 366 and 297 gallon jugs.
    • 366 = 1(297) + 69
      • 69 = 366 – 1(297)
    • 297 = 4(69) + 21
      • 21 = 297 – 4(69) = -4(366) + 5(297)
    • 69 = 3(21) + 6
      • 6 = 69 – 3(21) = 13(366) – 16(297)
    • 21 = 3(6) + 3
      • 3 = 21 – 3(6) = -43(366) + 53(297)
    • 6 = 2(3) + 0
    • -43(366) + 53(297) = 3
    • -1161(366) + 1431(297) = 81
example13
Example
  • How to save water (reduce number of rounds of transferring water)?
    • -297(366) + 366(297) = 0
    • -891(366) + 1098(297) = 0

-(1161-891)(366) + (1431-1098)(297) = 81

-270(366) + 333(297) = 81