Files
github/nok.sh
2026-02-28 14:24:49 +03:00

22 lines
354 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
if ! command -v gcd &> /dev/null; then
source ./nod.sh
fi
lcm() {
local a=$1
local b=$2
if [ $a -eq 0 ] || [ $b -eq 0 ]; then
echo 0
return 0
fi
local gcd_val=$(gcd $a $b)
local lcm_val=$((a * b / gcd_val))
echo $lcm_val
}
result=$(lcm $1 $2)
echo "НОК($1, $2) = $result"