Calculate GCD (JavaScript)
Program
Description
This JavaScript program calculates the greatest common divisor (GCD) of the given integers. The numbers must be between 0 and 253.
The algorithm being used is the classic GCD algorithm by Euclid, which is very fast.
The source code is available.
Examples
- gcd(0, 2) = 2
- gcd(3, 5) = 1
- gcd(24, 18) = 6