Flowchart: greatest common divisor, Euclid's algorithm

Until b is 0, replace a with b and b with the remainder of a divided by b. Then print a as the greatest common divisor.

Steps

  1. Start, then read two numbers a and b.
  2. Decide whether b is 0.
  3. If not, store the remainder of a divided by b in r.
  4. Put b into a and r into b, then go back to the decision.
  5. When b is 0, a is the greatest common divisor. Print it and end.

Good to know

Drawing happens in this browser only. Your text is never sent to a server. Symbol rules differ a little between textbooks, so check them against your course before you hand in.

See the symbol rules

More examples