Test whether the given number is prime or not Assignment Help

Assignment Help: >> Algorithms for Problem Solving >> Test whether the given number is prime or not

Test whether the given number is a prime number

 Prime Number: Prime Numbers are any of the positive integers greater than 1, and the prime numbers are those numbers, which is divisible only by itself and by 1 i.e. 2,3,5,7,11,13,...................

Algorithm:

Step 1: Start

Step 2: Take any positive non-zero value from the keyboard.

Step 3: Set value of divisor to 2.

Step 4:  Divide the number by divisor (i.e.2 first) If remainder is zero, then the given number is not prime, else the process is to continue.

Step 5: Increment  divisor by 1, divide  the  number  by  the  incremented  divisor  and  check If remainder is zero. Repeat the process till either the remainder becomes zero or until divisor is equal to the number itself. If remainder becomes zero at any stage, the number is not prime else it is prime if carried to last stage, till incremented divisor is the number itself.

Step 6: Stop.

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