Least Common Multiple

Find the least common multiple (LCM) of two numbers using the GCD-based formula.

Code

Algorithms
gcd() { [ "$2" -eq 0 ] && echo "$1" || gcd "$2" $(($1 % $2)); }
echo $(( (a * b) / $(gcd $a $b) ))

Parameters

First number

Second number

Server

More Bash Snippets