Find Prime Number Bash shell programming Linux and Unix OS

If the number is divided by itself and one then it is called prime no. 7 is the prime no, 4 is not prime number, using basic airthematic operation in bash shell programming in Linux and UNIX OS we can find the give number is prime number or not
Source code bash shell Programming Algorithm
echo "Enter the number"
read a
i=2
z=0
while [ $i -lt $a ]
do
s=`expr $a % $i`
if [ $s -eq $z ]
then
echo "Not Prime"
exit
else
i=`expr $i + 1`
fi
done
echo "Prime number"

OUTPUT Find PRIME NUMBER CS1252 Operating Systems lap
[redhat35@localhost Rhel5]$ sh prime.sh
Enter the number
7
Prime number
[redhat35@localhost Rhel5]$ sh prime.sh
Enter the number
4
Not Prime

Related post