代码:
#!/bin/bash
getmaxgy()
{
dividend=$1
divisor=$2
remainder=1
until [ "$remainder" -eq 0 ]
do
let "remainder = $dividend % $divisor"
dividend=$divisor
divisor=$remainder
done
}
getmaxgy $1 $2
echo
echo "max gongyue of $1 and $2 = $dividend";
echo
执行结果