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

โˆ™ 2010-02-26 12:32:39
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar
Study guides

Factoring and Multiples

21 cards

What is the prime factorization of 24

What is the prime factorization of 54

What is the prime factorization of 64

What is the prime factorization of 34

โžก๏ธ
See all cards
4.83
โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…
6 Reviews
More answers
User Avatar

Wiki User

โˆ™ 2010-02-26 12:32:39

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

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.)


What is algorithm to sum two natural numbers using c?

There is no algorithm. To add two numbers just put a + between them. int a = 1 + 2;


All even numbers from 2-100 using algorithm?

102


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.


Write an algorithm and Draw a flowchart to accept two numbers and display the sum of the numbers?

a+b=c


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.


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.


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


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.


Algorithm to find the smallest number among three numbers in C programming language?

It's an algorithm you want, or a C program? Here is the algorithm: min3 (a, b, c) := min2 (a, min2 (b, c)) min2 (x, y) := y if x>y; x otherwise


How do you describe an algorithm with rational numbers?

Describe an algorithm for dividing rational numbers.


How to check whether a set of numbers or relatively prime or not using java program?

Use Euclid's algorithm to find the greatest common factor. This algorithm is much simpler to program than the method taught in school (the method that involves finding prime factors). If the greatest common factor is 1, the numbers are relatively prime.


List two methods that can be used to find the greatest common factor of a set of numbers?

Prime factorization and the Euclidean algorithm


Are all prime numbers between C and 100 are odd?

All prime numbers are odd except for 2 which is the only even prime number


What is sub-algorithm?

It is an algorithm used by another algorithm as part of the second algorithm's operation.As an example, an algorithm for finding the median value in a list of numbers might include sorting the numbers as a sub-algorithm: There are plenty of algorithms for sorting, and the specifics of the sorting does not matter to the "median value" algorithm, only that the numbers are sorted when the sub-algorithm is done.For what an algorithm is, see related link.


How do you write a program in objective c numbers 1-100 prime numbers?

fdsgfhgdfhgdf


What prime numbers add up to C on a 100 grid?

The answer depends on what value C has.


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.


Write a C program to find the sum of all prime numbers?

Since there is an infinite set of prime numbers the answer would be infinity.


Which of these numbers is not a prime number A 21 B 31 C 41?

21 is not a prime.


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.


What is the algorithm for determining the maximum of two numbers?

Compare two numbers, a and b. If a is greater than b then return a, otherwise return b. In C, we can implement this algorithm using the ternary operator (?:), as follows: return a>b?a:b;


Line drawing algorithm in c language?

dda algorithm,bresenham's algorithm,midpoint algorithm..These are the few that are useful in my opinion.