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
1. use a small perl program and matching config file to retrieve and reformat the system time for a number of remote machines via snmp.  Readings should have a local timestamp for

I need a program that writes the first column of the matrix. The numbers in this column follow the pattern below: 1. Numbers start at 1 and count up to ''nels'' in increments of

Select two different architecture styles to design and implement a software system and provide its Architecture Diagrams (implement the software with java)

What is .NET TECHNOLOGY? .NET technological innovation was presented by Enthusiasm, to get the industry from the SUN's Coffee. Few in the past, Enthusiasm had only VC++ and VB

How to do socket programming in C

Design an application that opens and analyses word files. Requirements: Create an application that analyses text documents. It should open a text file, read each word in

Expertsmind.com is expert in java assignment help JAVA Virtual Machine A Java exclusive device or java virtual machine (JVM) is an exclusive device able of undertaking Jav

Please choose the best tutor to rewrite my assignment Ticket ID # EM201713THA711DSTN.because insructor does not accept. Thank you

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

Question 1 Discuss on UNIX kernel components 2 Explain process creation and process termination 3 When do a Deadlock occur? What are the Necessary Conditions for Deadlock