Algorithm to Check Whether the Given Number is Prime or Not
1
Algorithm to check whether the given number is Prime or not. Test: Let p be the given number. Find a whole number nearly greater than . Let k > Test whether p is divisible by any prime number less than k. If yes, p is not a prime. Otherwise, p is prime. Example: Is 391 a prime? Solution: Here p = 391 Clearly 20 > Prime numbers less than 16 are 2, 3, 5, 7, 11, 13, 17 and 19. We find that 391 is divisible by 17. So, it is not a prime.
-
Upload
amitbajajmaths -
Category
Documents
-
view
482 -
download
0
Transcript of Algorithm to Check Whether the Given Number is Prime or Not
![Page 1: Algorithm to Check Whether the Given Number is Prime or Not](https://reader036.fdocuments.in/reader036/viewer/2022082416/5527ece355034675588b458e/html5/thumbnails/1.jpg)
Algorithm to check whether the given number is Prime or not.
Test:
Let p be the given number. Find a whole number nearly greater than .Let k > Test whether p is divisible by any prime number less than k. If yes, p is not a prime. Otherwise, p is prime.
Example:Is 391 a prime?
Solution:Here p = 391Clearly 20 > Prime numbers less than 16 are 2, 3, 5, 7, 11, 13, 17 and 19.We find that 391 is divisible by 17.So, it is not a prime.