Calculate GCD (JavaScript)
Program
Description
This JavaScript program calculates the greatest common divisor of the given two non-negative integers of arbitrary size. It also shows the calculation steps, comprising the sequence of remainders and the extra coefficients in the extended Euclidean algorithm.
The source TypeScript code and compiled JavaScript code are available for viewing.
Examples
- gcd(0, 2) = 2.
- gcd(3, 5) = 1.
- gcd(24, 18) = 6.