How to find a prime number

How to find a prime number

Articles Hits: 76

The most known ways to find the list of prime numbers up to some value is a sieve of Eratosthenes, Sundaram's sieve and Atkin's sieve. To check whether this number is prime, there are tests of simplicity

It is required to you

Instruction

1. Way 1. Eratosthenes's sieve. By this method to find all prime numbers there is no more certain value X, it is necessary to write out in a row all integers from one to X. Let's take number 2 as the first prime number. Let's strike off the list all numbers which are divided into 2. Then we will take the following after the two, not deleted number, and we will strike all numbers which are divided into the number taken by us off the list. And further every time we will take the following not deleted number and to strike all numbers which are divided into the number taken by us off the list. And so until the number chosen by us does not become more, than X/2. The deleted numbers which remained in the list not all are prime

2. Way 2. Sundaram's sieve. All numbers types + at + 2khu where indexes x (not bigger s) run all natural values for which x + at +2khu N, namely values x =1, 2..., ((2N+1)1/2-1)/2 and x = at, x +1..., (N-x) / (the 2nd +1) yu there is no more are excluded from a number of natural numbers from 1 to N. Then each of the remained numbers is multiplied by 2 and increases by 1. The sequence received as a result represents all odd prime numbers among from one to 2N+1.

3. Way 3. Atkin's sieve. Atkin's sieve represents a difficult modern algorithm of finding of all prime numbers to a preset value of X. The main essence of an algorithm consists in representation of prime numbers as the representations, whole with odd number, in these square shapes. The separate stage of an algorithm eliminates numbers, multiple to squares of prime numbers in the range from 5 to X.

4. Tests of simplicity. Tests of simplicity are the algorithms allowing to define whether concrete number X is simple. One of the simplest, but also labor-consuming tests is a search of dividers. It consists in the device of all integers from 2 to a square root of X and in calculation of a remainder of division of X on each of these numbers. If number X remainder of division on some number (more than 1 and less than X) is equal to zero, then number X is compound. If comes to light that number X cannot be reduced without the rest by one of numbers, except unit and itself, then number X simple. Except this way there is also large number of other tests for testing of simplicity of number. The majority of these tests are probabilistic and are used in cryptography. The only test guaranteeing receiving the answer (AKS test) is very difficult in calculation that it complicates its practical application

Author: «MirrorInfo» Dream Team

Print