Breaking News
You are here: Home / Program Code / UNIX / write a script to enter the number & check whether the number is prime number or not.

write a script to enter the number & check whether the number is prime number or not.

$vi prime.sh 
echo -e "\n Enter number:\c"
read no
 
i=2      
 
while [ $i -lt $no ]
do
 
        mod=`expr $no % $i`
 
        if [ $mod -eq 0 ]
        then
                echo -e "\n number is not prime "
                exit
        else
                i=`expr $i + 1`
        fi
 
done
 
echo -e "\n The number is prime"
 
:wq

Download Paper Solutions from Below Link

About admin

Scroll To Top