answersLogoWhite

0


Best Answer

check if 2 divides the Number

check if 3 divides the Number

check if 5 divides the Number

...

check if any prime numbers less than the square root of the Number divide the Number

If any do, the Number is composite; otherwise the Number is prime.

This is called the Sieve of Erasthenes.

An easy way to check if a Prime number divides the Number in base ten (if you don't have a calculator) is to add or subtract 1 or 3 times the prime number to the Number, so that the sum or difference is a multiple of ten (if the prime number isn't 2 or 5). Knock off the zero. If the prime number divides the new number, it also divides the Number; otherwise it doesn't.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Algorithm to find whether a number is prime or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write the algorithm and draw the flowchart to find Sum of N Prime number?

Shrek and Donkey


An algorithm to find whether a directed graph is connected or not?

You can use a The Depth-First Search algorithm.


What is a method to create a prime number?

No specific method has been discovered so far,not even by the greatest mathematicians,to create a prime number or to find out all the prime numbers......but there's a way to find whether a number is prime or not,i.e,by dividing that number with the first prime nos. such as 2,3,5,7,11 and so on and seeing whether it is exactly divisible or not.If it is not,then it can be classified as a prime no.


How do you find Number of prime numbers below certain number?

You just have to work out it,take each number below it and check whether it is prime or not.


How do you find 2 prime numbers that if multiplied would generate a 400-digit number?

You seek for prime numbers that are approximately 200 digits big, then multiply them. I don't know details about the algorithms, but I understand that for cryptography, instead of using an algorithm that will be guaranteed to give a prime number, an algorithm is used, instead, that has a very, very high probability of giving a prime number. Probably this is done because it is faster.


Algorithm to find prime numbers below ten?

Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.Take each number in turn, call it "n", and check whether it has any factors f, such that 1 < f < n. If it doesn't, it is a prime number.


How do you find prime numbers between 2 and 70?

You can check each individual number, whether it is a prime number. For numbers below 100, it is enough to check whether they are divisible by 2, by 3, by 5, and by 7. If a number is divisible by none of these, it is a prime number.


What is the algorithm of LCM of more than 3 numbers?

If you use methods based on prime factors, it is the same whether you have 2, 3, or more numbers: find all the factors that occur in any of your numbers. If you use a method based on Euclid's Algorithm (that is, lcm(a, b) = a x b / gcf(a, b), where you find the gcf with Euclid's Algorithm), then you can find the lcm for two numbers at a time. For example, to get the lcm of four numbers, find the lcm of the first two, then the lcm of the result and the third number, than the lcm of the result and the fourth number.


How can find prime number by using if in vbscript?

Dim prime, nprime = TRUEn=cint(inputbox("Enter a number to find whether it is Prime or Not"))for i=2 to (n-1)If n mod i = 0 thenprime = FalseExit forEnd ifNextIf prime thenmsgbox "Yes! It is a Prime number"Elsemsgbox "No! it is not a prime number"End if


Write a java programme to check whether the number is twin prime or not?

Find a prime number, add 2 to the number. Check if the new number is prime. IE : 3 is prime. 3+2 =5. 5 is prime. (3,5) are twin primes.


How do you find the prime factorization of 34?

One way to find the prime factorization of a number is to start with the lowest prime number and see if it evenly divides the number. If it does, check whether the result of the division is divisible by that same prime number. When the prime number you are testing does not evenly divide that number, continue with the next prime number. Continue this until the result of the division is a prime number.Check whether 34 is divisible by 2:34 &divide; 2 = 1717 is a prime number, so the prime factorization is finished.The prime factorization of 34 is 2 x 17.Another way to find the prime factorization of a number is to choose a factor pair for that number. Then, find a factor pair for each of those numbers that is not prime.A factor tree of 34 is34/ \2 17Both 2 and 17 are prime, so the tree is finished.The prime factorization of 34 is 2 x 17.


How do you find the LCM of a composite number?

You need at least two numbers to find an LCM. It doesn't matter whether they are prime or composite.