4 ms·
Once you go to the trouble of naming the script, might as well show off a recursive version as well: #!/bin/sh a=$1 b=$2 # base case if [ $b -eq 0
by akkartik 12y ago
Once you go to the trouble of naming the script, might as well show off a recursive version as well:
#!/bin/sh
a=$1
b=$2
# base case
if [ $b -eq 0 ]
then
echo $a
exit
fi
echo $(./gcd.sh $b $(($a % $b)))