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
While working in the eHealth Applied Research lab at Mohawk College, you are asked to transform an xml file into an XHTML representationusing XSLT for display in a browser.The xml

In this portion of the lab you will analyze a problem and create a Raptor program to solve it.  Make sure you use a class in Raptor and in Python to solve the problem.  Read the fo

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

Write a program to draw the figure shown below. the program must provide: a. Close the fish's mouth slowly (at least 5 moves from the original position to close the mouth) b.

hi, can you help me with testing java classes I have wrote using java and jsp and servlet in eclipse ? I want to use JUnit for testing

develop a pseudocode algorithm to determine the total amount of extra cost changed to the organizers for expenses accurednduring the workshop. the code is to be written for an unde

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

1 Triple Eigenvalue with 2 Linearly Independent Eigenvectors       In this case we will have the eigen-value l with the two linearly independent eigenvectors  ?h 1 and  ?h 2

Define Reasons for using Functions? 1. Evade rewriting the same code over and over. 2. It is simpler to write programs and keep track of what they are doing. Codes are able t

Provide Example of Function? An illustration of a function definition main() { message(); } /* header */ message() { /*bodystarts here*/ printf ("Example for function