Добавил НОК

This commit is contained in:
gyg72
2026-02-27 21:16:51 +00:00
parent c91f2fc57e
commit 675affe729

25
script_LCM.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Использование: $0 <число1> <число2>"
exit 1
fi
a=$1
b=$2
gcd() {
local x=$1
local y=$2
while [ $y -ne 0 ]; do
local t=$((x % y))
x=$y
y=$t
done
echo $x
}
gcd_val=$(gcd $a $b)
lcm=$(( (a * b) / gcd_val ))
echo $lcm