Files
github/nod.sh
2026-02-28 14:24:01 +03:00

25 lines
354 B
Bash

#!/bin/bash
gcd() {
local a=$1
local b=$2
if [ $a -eq 0 ]; then
echo $b
return 0
fi
if [ $b -eq 0 ]; then
echo $a
return 0
fi
while [ $b -ne 0 ]; do
local temp=$b
b=$((a % b))
a=$temp
done
echo $a
}
result=$(gcd $1 $2)
echo "НОД($1, $2) = $result"