How to resolve the algorithm Greatest common divisor step by step in the Draco programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Greatest common divisor step by step in the Draco programming language

Table of Contents

Problem Statement

Find the greatest common divisor   (GCD)   of two integers.

Greatest common divisor   is also known as   greatest common factor (gcf)   and   greatest common measure.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Greatest common divisor step by step in the Draco programming language

Source code in the draco programming language

proc nonrec gcd(word m, n) word:
    word t;
    while n ~= 0 do
        t := m;
        m := n;
        n := t % n
    od;
    m
corp

proc nonrec show(word m, n) void:
    writeln("gcd(", m, ", ", n, ") = ", gcd(m, n))
corp

proc nonrec main() void:
    show(18, 12);
    show(1071, 1029);
    show(3528, 3780)
corp

  

You may also check:How to resolve the algorithm Bézier curves/Intersections step by step in the Go programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the Applesoft BASIC programming language
You may also check:How to resolve the algorithm Flipping bits game step by step in the MiniScript programming language
You may also check:How to resolve the algorithm String length step by step in the Nim programming language
You may also check:How to resolve the algorithm Range expansion step by step in the F# programming language