read a b r=$((a % b)) if [ $r -eq 0 ]; then echo $b else echo $r fi