echo "Enter the number"
read c
p =0
for((i=1;i<=c;i++))
do
r =`expr $c % $i`
if [ $r -eq 0 ]
then
p =`expr $p + 1`
fi
done
if [ $p -eq 2 ]
then
echo "Prime"
else
echo "Not Prime"
fi
Output -> Enter the number
3
Prime
read c
p =0
for((i=1;i<=c;i++))
do
r =`expr $c % $i`
if [ $r -eq 0 ]
then
p =`expr $p + 1`
fi
done
if [ $p -eq 2 ]
then
echo "Prime"
else
echo "Not Prime"
fi
Output -> Enter the number
3
Prime
No comments:
Post a Comment