Unix Shell Program To Print Range of Prime No
Unix Shell Program To Print Range of Prime No
Range.
Program:
echo enter the range
read n
i=1
echo prime no.s are
while test $i -le $n
do
m=$i
b=0
c=0
j=1
while test $j -le $m
do
c=`echo $m % $j | bc`
if test $c -eq 0
then
b=`echo $b + 1 | bc`
fi
j=`echo $j + 1 | bc`
done
if test $b -eq 2
then
echo $m
fi
i=`echo $i + 1 | bc`
done