#! /bin/csh -f set usage = "$0 NUM" # outputs the approximate square root of $1. set T = "$1"; shift; if ( $#argv != 0 ) then echo "usage: ${usage}"; exit 1 endif @ T = ${T} if ( ${T} == 0 ) then echo "0"; exit 0 endif if ( ${T} == 1 ) then echo "1"; exit 0 endif @ R = ${T} @ Q = ( ( ${T} - 1 ) / ${R} ) + 2 while ( ${Q} < ${R} ) @ R = ( ${R} + ( ( ${T} + ${R} - 1 ) / ${R} ) + 1 ) / 2 @ Q = ( ( ${T} - 1 ) / ${R} ) + 2 end @ W = ${R} - 1 echo ${W}