W.A.S.S to check that whether a given number is prime or not.
Program
# W.A.S.S to check that whether a given number is prime or not.
echo -e " enter number \c"
read number
i=2
flag=0
while test $i -lt $number #starts from 2 to number-1
do
if test `expr $number % $i` = 0 #if the no is completely divisible by i
then
flag=1
break
fi
i=`expr $i + 1`
done
if test $flag = 0
then
echo "Number is prime"
else
echo "Number is not prime"
fi
Output
enter number 55
Number is not prime
enter number 13
Number is prime
enter number 21
Number is not prime