12/03/16 22:27:13.29
>>557
できたよ。GCMとLCMの計算方法が対称的になるようにしたよ。
/bin/sh純正だ。アルゴリズムはウケ狙いだけどな。
#!/bin/sh
GCM=$1
while :; do
for i in "$@"; do
if [ `expr "$i" % "$GCM"` != 0 ]; then
GCM=`expr "$GCM" - 1`
continue 2
fi
done
echo GCM = "$GCM"
break
done
LCM=$1
while :; do
for i in "$@"; do
if [ `expr "$LCM" % "$i"` != 0 ]; then
LCM=`expr "$LCM" + 1`
continue 2
fi
done
echo LCM = "$LCM"
break
done