flag=0
for ((index=2 ; index <= $1/2 ; index++))
do
if [ `expr $1 % $index` -eq 0 ]
then
flag=1
break
fi
done
if [ $flag -eq 0 ]
then
echo "Prime"
else
echo "Not Prime"
fi
OUTPUT:-
#!/bin/bash
#[root@localhost scripts]# ./prime 7
#Prime
for ((index=2 ; index <= $1/2 ; index++))
do
if [ `expr $1 % $index` -eq 0 ]
then
flag=1
break
fi
done
if [ $flag -eq 0 ]
then
echo "Prime"
else
echo "Not Prime"
fi
OUTPUT:-
#!/bin/bash
#[root@localhost scripts]# ./prime 7
#Prime
0 comments:
Post a Comment