Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. 2011-02-06
  2.  
  3.  
  4. Division Algorithm
  5.  
  6. For any two integers (natural numbers) a < b, there are natural numbers q, r so that:
  7. b = aq + r 0 ≤ r < a
  8.  
  9. For instance:
  10.  
  11. b = 7 a = 2 7 = 2(3) + 1
  12. b = 12 a = 2 12 = 2(6) + 0
  13.  
  14. If a = 2, the possible remainders are: 0,1
  15. If the remainder is 0, we call b even.
  16. If the remainder is 1, we call b odd.
  17.  
  18. b = 17 a = 3 17 = 3(5) + 2
  19. 17 = 3(q) + r
  20. 17 = 3(5) + r
  21. 17 = 15 + r
  22. r = 2
  23. Possible remainders: 0, 1, 2
  24.  
  25.  
  26. Euclid's Algorithm
  27.  
  28. Euclid's algorithm is used to determine the fastest common divisor (GCD) of two natural numbers. It uses the division algorithm.
  29.  
  30. b = a(q1) + r1
  31. / /
  32. / /
  33. / /
  34. a = r1(q2) + r2
  35.  
  36. r1 = r2(q3) + r3
  37.  
  38. rn-1 = rn(qn+1) ← we eventually get a remainder of zero
  39.  
  40. rn is the largest number that divides both a & b, in other words, it is the GVD of a, b.
  41.  
  42. r = b - a(q)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement