shell script to check that a given number is prime or not, Programming Languages

 W.A.S.S to check that whether a given number is prime or not.

 Program

 

# W.A.S.S to check that whether a given number is prime or not.

 echo -e " enter  number \c"

read number

i=2

flag=0

 

while test $i -lt $number                            #starts from 2 to number-1

do

    if test `expr $number % $i` = 0            #if the no is completely divisible by i

    then

           flag=1

           break

    fi

    i=`expr $i + 1`

done

 

if test $flag = 0

then

    echo "Number is prime"

else

    echo "Number is not prime"

fi

 

Output

enter  number 55

Number is not prime

 

enter  number 13

Number is prime

 

enter  number 21

Number is not prime

 

Posted Date: 9/26/2012 4:27:33 AM | Location : United States







Related Discussions:- shell script to check that a given number is prime or not, Assignment Help, Ask Question on shell script to check that a given number is prime or not, Get Answer, Expert's Help, shell script to check that a given number is prime or not Discussions

Write discussion on shell script to check that a given number is prime or not
Your posts are moderated
Related Questions
Type of Linear Programming - DEA The Express Dry Cleaners currently has four locations in the Chicago area and willing be opening the fifth in the very near future.  Mr. James,

code for using tree view control and fill it with database

Implement the "Nuclear Reactor" example using the following:  An ISR triggered by a button press  A task to update the temperatures  A semaphore to communicate between the ISR and

how to store multidimensional array in a single column in mysql database using MATLAB?


write and compile a simple program in Assembly Language that compute and print student grades for a course.which you can open a file, read from it, and compute the results...using

What are Attributes in HTML langauge? A few tags have attributes. An attribute is a name, followed through an = sign, followed by the value. For instance, to make a centered H1

You will soon receive in an email a personalized assignment that tells you the nature of the "Empirical Data" you are to produce with a Pascal program for HW3. HW3 is about generat

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Lazytown Constabulary are concerned that young people in the town are unaware of the sorts of crime that they might encounter in their daily lives and are concerned that they may b