Prime Numbers: Prime Numbers
|
|
Prime Numbers
Properties of a prime number
Primes numbers are:
- Positive integers, greater than one
- Numbers that have only two distinct factors, 1 and itself
- Numbers that cannot be expressed as the product of two smaller integers
Determining if a number, n, is a prime
If the primes less n are known, then a check can be made to see if any of these primes are a factor of p.
If at least one of these primes is a factor, then n is not a prime, otherwise n is a prime number.
A more optimal test:
- Let q be the largest integer less than the square root of p
- Just the primes less than q are checked to see if they are factors of n
- If a prime, p, greater than q is a factor of n, then n/p is less than q and is prime or contains a smaller prime factor
Finding a list of the prime numbers less that n
This can be done by listing all of the natural numbers up to n and then removing all multiples of each prime as it is found,
starting with 2. This method is know as the prime sieve of Eratosthenes.
Facts about Prime Numbers
- 2 is the only even prime number
- There are infinitely many prime numbers
- There is no formula for the nth prime number
- Let xn be the product of the all the prime numbers up to the nth prime number, pn.
The number (xn + 1) is either prime of has a prime factor that is greater than pn.
List of Primes
Primes generated using the prime sieve of Eratosthenes
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
List of primes
The prime sieve of Eratosthenes
Generating primes to a maximum value of n
- Create a grid with the number values from 1 to n
- Highlight all of the grid values except for the value 1
- Calculate x, the square root of n rounded down.
- Move through the grid starting at 2 and up to the value of x
- If a highlighted value if found, unhighlight all of the multiples of that value in the grid
- When the process has been completed, the remaining hightlighted values are the prime numbers
Example: primes between 1 and 100
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
| 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
| 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |
| 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
| 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
| 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 |
| 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
Square root of 100 is 10
Starting value is 2
Special Primes
A list of primes that have a specific format
Mersenne Primes
Primes of the form 2p - 1 (p is always prime)
1: 21 - 1
3: 22 - 1
7: 23 - 1
31: 25 - 1
127: 27 - 1
8191: 213 - 1
131071: 217 - 1
524287: 219 - 1
2147483647: 231 - 1
Fermat Numbers
Primes of the form 2n + 1 (n is always a power of 2)
3: 21 + 1
5: 22 + 1
17: 24 + 1
257: 28 + 1
65537: 216 + 1
Prime Factors
A tool to generate the prime factors of a given positive integer
Goldbach's Conjecture
Goldbach's conjecture states that every even integer greater than two is the sum of two prime numbers.
This tool finds all the different sums of two prime numbers for every even number between a given range of values.
4 |
|
6 |
|
8 |
|
10 |
|
12 |
|
14 |
|
16 |
|
18 |
|
20 |
|
22 |
|
24 |
|
26 |
|
28 |
|
30 |
|
32 |
|
34 |
|
36 |
|
38 |
|
40 |
|
42 |
|
44 |
|
46 |
|
48 |
|
50 |
|
52 |
|
54 |
|
56 |
|
58 |
|
60 |
|
62 |
|
64 |
|
66 |
|
68 |
|
70 |
|
72 |
|
74 |
|
76 |
|
78 |
|
80 |
|
82 |
|
84 |
|
86 |
|
88 |
|
90 |
|
92 |
|
94 |
|
96 |
|
98 |
|
100 |
|
