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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Greatest common divisor step by step in the 11l 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 11l programming language

Source code in the 11l programming language

F gcd(=u, =v)
   L v != 0
      (u, v) = (v, u % v)
   R abs(u)

print(gcd(0, 0))
print(gcd(0, 10))
print(gcd(0, -10))
print(gcd(9, 6))
print(gcd(6, 9))
print(gcd(-6, 9))
print(gcd(8, 45))
print(gcd(40902, 24140))

  

You may also check:How to resolve the algorithm Literals/Floating point step by step in the Pascal programming language
You may also check:How to resolve the algorithm Ultra useful primes step by step in the Ruby programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the J programming language
You may also check:How to resolve the algorithm Periodic table step by step in the Phix programming language
You may also check:How to resolve the algorithm Anti-primes step by step in the FutureBasic programming language