For b 3 if a b then assign b to c 4 if a b then assign

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: from c 7: return c 8: end a b c 16 12 12 remainder(a, c) remainder(b, c) Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 12 remainder(16, 12) remainder(12, 12) Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 12 remainder(16, 12) 4 remainder(12, 12) 0 Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 12 remainder(16, 12) 4 0 remainder(12, 12) 0 Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 11 Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 11 remainder(16, 11) 5 0 remainder(12, 11) 1 0 Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 10 remainder(16, 10) 6 0 remainder(12, 10) 2 0 Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 9 remainder(16, 9) 7 0 remainder(12, 9) 3 0 Demo of "Greatest Common Factor" 1: Request a value for a 2: Request a value for b 3: if a b then assign b to c 4: if a < b then assign a to c 5: while (remainder(a, c)0 OR remainder(b, c)0) 6: subtract one from c 7: return c 8: end a b c 16 12 8 remainder(16, 8) 0 remainder(12, 8) 4 0 Demo of "Greatest Common Factor" 1:...
View Full Document

Ask a homework question - tutors are online