answersLogoWhite

0


Best Answer

Here is a very simple algorithm: Call your number "n". You might test divisibility by every number, starting at 2. If the first number by which a number is divisible is equal to "n", then it is a Prime number. - Faster algorithms are possible; for example, you really only need to test divisibility by all numbers, up to the square root of your number "n".

Here is a very simple algorithm: Call your number "n". You might test divisibility by every number, starting at 2. If the first number by which a number is divisible is equal to "n", then it is a prime number. - Faster algorithms are possible; for example, you really only need to test divisibility by all numbers, up to the square root of your number "n".

Here is a very simple algorithm: Call your number "n". You might test divisibility by every number, starting at 2. If the first number by which a number is divisible is equal to "n", then it is a prime number. - Faster algorithms are possible; for example, you really only need to test divisibility by all numbers, up to the square root of your number "n".

Here is a very simple algorithm: Call your number "n". You might test divisibility by every number, starting at 2. If the first number by which a number is divisible is equal to "n", then it is a prime number. - Faster algorithms are possible; for example, you really only need to test divisibility by all numbers, up to the square root of your number "n".

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Here is a very simple algorithm: Call your number "n". You might test divisibility by every number, starting at 2. If the first number by which a number is divisible is equal to "n", then it is a prime number. - Faster algorithms are possible; for example, you really only need to test divisibility by all numbers, up to the square root of your number "n".

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the algorithm for prime numbers in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write an algorithm to check whether a number is a prime number or not?

You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.


What is an algorithm for multiplying rational numbers?

The algorithm is A/B * C/D = AB/CD.


Is there an algorithm that yields only prime numbers?

What exactly do you mean "yields only prime numbers"? If you mean a formula that when given the numbers n=1, 2, 3, ... and so on generates the nth prime number (or a different prime number for each n) then no. If you mean an algorithm whereby a number can be tested to be a prime number then yes. (Using this prime_test algorithm, a simple algorithm can be written that would supply numbers one at a time to it and use its result to decide whether to yield the tested number or not, only yielding those numbers which pass the test.)


Did eratosthenes make a mistake in prime numbers?

The algorithm for identifying prime numbers which is known as the Sieve of Eratosthenes has been accepted as accurate for thousands of years.


All even numbers from 2-100 using algorithm?

102


What is the GCF of 180 336 and 504?

You can use Euclid's algorithm to calculate the gcf of two of the numbers - then use Euclid's algorithm again with the result and the third number.Or you can factor all the numbers into prime factors, and check which prime factors occur in all three numbers.


Design a algorithm to generate all prime numbers within the limits l1 and l2?

Algorithm: to generate all prime numbers between the limits l1 and l2.Input: l1 and l2Output: Prime numbers between l1 and l2Method:for (n=l1 to l2 in steps of 1 do)prime=truefor (i=2 to n/2 in steps of 1 do)if (n % i =0)prime = falsebreakend_ifend_forif (prime = true)Display 'Prime number is =', nend_for


How many prime numbers are located on sieve of erastosthenes?

The sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit.


Is there any specific formula for finding out that the given numbers are relatively prime?

Euclid's algorithm is probably the most commonly used 'formula' for that purpose. If the greatest common factor is 1, the numbers are relatively prime. See the related question for an example of Euclid's algorithm.


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.


How do you describe an algorithm with rational numbers?

Describe an algorithm for dividing rational numbers.


Develop an algorithm to display all prime numbers from 2 to 100 Give both the pseudocode version and the flowchart version Convert your pseudocode into a Java program?

Develop an algorithm to display all prime numbers from 2 to 100. Give both the pseudocode version and the flowchart version. Convert your pseudocode into a Java program.