TotalCodes
Menu
Android
Data Structure
Oracle(PL/SQL)
Shell Scripts
Monday, 27 May 2013
Shell Script to find prime number
echo "enter the number"
read a
i=2
flag=1
a1=`expr $a - 1`
while test $i -le $a1
do
rem=`expr $a % $i`
if test $rem -eq 0
then
flag=0
break
else
i=`expr $i + 1`
fi
done
if test $flag -eq 0
then
echo "$a is Composite"
else
echo "$a is Prime"
fi
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment