26 lines
401 B
Bash
Executable File
26 lines
401 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Function to find GCD using Euclidean algorithm
|
|
gcd() {
|
|
local a=$1
|
|
local b=$2
|
|
|
|
while [ $b -ne 0 ]; do
|
|
local temp=$b
|
|
b=$((a % b))
|
|
a=$temp
|
|
done
|
|
|
|
echo $a
|
|
}
|
|
|
|
# Check arguments
|
|
if [ $# -ne 2 ]; then
|
|
echo "Usage: $0 <number1> <number2>"
|
|
exit 1
|
|
fi
|
|
|
|
# Call function and print result
|
|
result=$(gcd $1 $2)
|
|
echo "НОД($1, $2) = $result"
|