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

Assignment Help:

 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

 


Related Discussions:- shell script to check that a given number is prime or not

Count no of files, Normal 0 false false false EN-US X...

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

Draw a use case diagram in uml for order book, SailDublin Ferry provides fe...

SailDublin Ferry provides ferries to mainland Britain, Europe and America. Having observed the success of Irish ferries and Stennaline online booking system; SailDublin ferry has d

Wap for intelligent agent able to play block dominoes game, Objective: ...

Objective: In a programming language of your choice, write an intelligent agent able to play block Dominoes against a player. Together with this assignment you will find two pa

Define the if statement - computer programming, Define the The if statement...

Define the The if statement - Computer Programming? The if statement is an influential selection statement and is used to control the flow of execution of statements. One of th

Explain inheritance and polymorphism in lingo programming, Question: (a...

Question: (a) Explain the concepts of Inheritance and Polymorphism in Lingo programming. (b) Write short descriptions on parent scripts and child objects in Lingo object

Decision table, If it is a weekday and it is not a holiday, then you go to ...

If it is a weekday and it is not a holiday, then you go to work. However, if it is a weekday and it is a holiday, then what you do depends on the weather. If it is raining, you pla

Program for create the rna sequence from the dna, Often, DNA sequences are ...

Often, DNA sequences are represented as a sequence of characters (String) and each character in the sequence corresponds with one of four nucleotides. A = adenine, C = cytosine,

Cobol 85, Open error message coming out when compiling

Open error message coming out when compiling

Java multithreaded programming, Expertsmind brings you unique solution in ...

Expertsmind brings you unique solution in java assignments Multithreaded Programming Java provides built-in support for multithreaded selection. A multithreaded applicatio

Write a perl script that accepts two integer arguments, 1. Write a Perl scr...

1. Write a Perl script that accepts exactly 2 integer arguments where the first argument must be less than the second argument. The script will print a comma separated list of inte

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd