Skip to content

GCD (Euclid)

Pascal while + I/O

Same task in: GoPHPRust

Flowchart (ISO 5807)

YesNoStartInput a, bb ≠ 0t = bb = a mod ba = tOutput aEndFigure 1 — GCD

Source code

Pascal
program GCD;
var a, b, t: integer;
begin
  readln(a, b);
  while b <> 0 do
  begin
    t := b;
    b := a mod b;
    a := t;
  end;
  writeln(a);
end.

The editor opens with this code — change it and the chart redraws.

Language
Pascal
Constructs
while + I/O
Topic
Algorithms
Formats
Word, Visio, draw.io, PDF, SVG

Related examples