echo Enter a number
read num
i=2
flag=1
while [ $i -lt $num ]
do
a=`expr $num % $i`
if [ $a -eq 0 ]
then
flag=0
fi
i=`expr $i + 1`
done
if [ $flag -eq 0 ]
then
echo $num is not a Prime number
else
echo $num is a Prime number
fi
Sunday, 29 October 2017
Subscribe to:
Post Comments (Atom)
there is an error in this logic.. loop must be stooped with break when flag is found 0 or otherwise it will keep number checking for next iteration and result will be irrelevant...
ReplyDeleteIn any case, numerous sort of site write, for example, arranged advertisements, discussion, informal community, social bookmark and the other content that isn't accessible in the free web content.
ReplyDeletescript coverage