PRIME NUMBER


SOURCE CODE:
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:

[examuser35@localhost Jebastin]$ sh prime.sh
Enter the number
7
Prime number
[examuser35@localhost Jebastin]$ sh prime.sh
Enter the number
4
Not Prime
Previous
Next Post »

Still not found what you are looking for? Try again here.