Files
lab_git/script_GCD.sh
2026-04-19 12:31:07 +03:00

15 lines
254 B
Bash
Executable File

#!/bin/bash
gcd() {
local a=$1 b=$2
while [ $b -ne 0 ]; do
local temp=$b
b=$((a % b))
a=$temp
done
echo $a
}
if [ $# -ne 2 ]; then
echo "Usage: $0 <num1> <num2>"; exit 1
fi
echo "НОД($1, $2) = $(gcd $1 $2)"