**AIM:**

To write a shell program to check whether the given number is prime or not.

**ALGORITHM:**

· Get the given string.

· Separate the digits using the formula q=`expr $n % 10`.

· Calculate sum of cube of digits by the formula a=`expr $a + $r /* $r /* $r`.

· Compute the and display result .

**PROGRAM SOURCE CODE**

echo ”enter the number”

read n

c=0

i=2

t=`expr $n-1`

while [ $i –le $t ]

do

q= `expr $n % $i `

if [ $q=0 ]

then

c=`expr $c + 1`

fi

i=`expr $i + 1`

done

if [ $c –eq 0 ]

echo “the number $n is prime number”

else

echo “the number $n is not prime number”

fi

**CONCLUSION:**

Thus the shell program to check whether a number is prime or not is written and executed successfully.

## No comments:

Write comments