Greatest Common Divisor

Find the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.

Code

Algorithms
while [ "$b" -ne 0 ]; do t=$b; b=$((a%b)); a=$t; done; echo $a

Parameters

First number

Second number

Server

More Bash Snippets