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

Building an e-store website in xhtml, The last exercise of each assignment ...

The last exercise of each assignment will be continuous from assignment to assignment and will have the goal of building an e-store website by the end of the course. For the fir

Write a program that should read input from a text file, A hardware store s...

A hardware store sells the following hardware tools: screwdriver, wrench, and tape measure. You are asked to calculate the profit for the store based on the number of tools sold an

Created xml document using the css stylesheet, After studying the concept, ...

After studying the concept, terminology, and implementation of CSS stylesheets, create a stylesheet to accompany your solutions to Question 1. A rich collection of styles should be

Produce a hierarchy chart-a structured flowchart, Produce a hierarchy chart...

Produce a hierarchy chart, a structured flowchart, and a Pascal program (with appropriate comments) to generate the Sales Commission Report shown below. The commission for each sal

Write a perl program to design a computer game, Write a Perl program ghici....

Write a Perl program ghici.pl, one of the simplest computer games. The program should generate a random integer between 1 and 1000 and asks the user to guess it. If the user ?nds t

Javascript variables and datatypes, Let us first see the skeleton of a Java...

Let us first see the skeleton of a JavaScript file. JavaScript code should be written between the and tags. The value LANGUAGE = "JavaScript" indicates to the browser that J

Visual basic a simple help, hello there, I making a program for the collage...

hello there, I making a program for the collage but I got stuck at one point, I have a timmer that moves object pnl with the pnl.left function, but I want it when it gets to end of

C# XNA Game Development, I need help for C# XNA 2Dimension Game Development...

I need help for C# XNA 2Dimension Game Development. I am gonna send the question and my solution(incomplete). I need you to complete it. Can you help me about that. I have 6-7 days

Python, please decode the following as it is answer for my assisgnment for ...

please decode the following as it is answer for my assisgnment for python: Ñò üOLOc  @ s‚ d „ Z d „ Z g Z xYe oQe ƒ e d ƒ i ƒ Z e d j oI e d

Describe url and hostname part, Describe URL and hostname part? The hos...

Describe URL and hostname part? The hostname part of the URL should be a valid Internet hostname. It can also be an IP address like as 204.29.207.217 or 128.235.252.184. The

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