# find whether the entered number is prime or not.

*
Posted By Akash Kurup on September 14, 2014 *

Script: –

echo “Enter a number: ”

read num

i=2

f=0

while [ $i -le `expr $num / 2` ]

do

if [ `expr $num % $i` -eq 0 ]

then

f=1

fi

i=`expr $i + 1`

done

if [ $f -eq 1 ]

then

echo “The number is composite”

else

echo “The number is prime”

fi

Output: –

Enter a number:

5

The number is Prime

Facebook

Google+

LinkedIn

E-mail

Founder and C.E.O, World4Engineers
Educationist and Entrepreneur by passion.
Orator and blogger by hobby

Website: http://world4engineers.com