(42, all flavours) Integer Division - how?
|
12-21-2020, 07:35 PM
Post: #55
|
|||
|
|||
RE: (42, all flavours) Integer Division - how?
(12-21-2020 03:20 PM)Albert Chan Wrote: a = q*b + s*h I was being stupid, why mod 9 test, when we could do mod 10 ? Again, b cannot have factors of 10 (nonzero last digit) Redoing previous post examples, but with mod-10 test a/b = 6900 / 120 = 690 / 12 = 57.5 q = 58 h = b/2 = 6 a-h ≡ 0 - 6 ≡ 4 q·b ≡ 8 * 2 ≡ 6 → s≠1, return q-1 = 57 2nd example a = -a; q = -q a-h ≡ (-0) - 6 ≡ 4 q·b ≡ (-8) * 2 ≡ 4 → s=1, return q = -58 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 12 Guest(s)