# sample showing loop counting with expr and arithmetic with bc
#! /bin/sh

# initialize values
i=0
j=0
k=0

# beginning of loop
while [ "$i" -ne "6" ]
do
	echo "i=$i   j=$j   k=$k"

	# compute j = $i/2
	j=`bc -l <<-END
		scale=4
		$i / 2
	END`

	# compute k = $i * $j
	k=`bc -l <<-END
		scale=4
		$i * $j
	END`

	# compute update loop counter
	i=`expr $i + 1`
done

exit 0
