Maths and Computing:

menu
 
Home
Binary
Books
Boolean
Calculators
Coding
Computing
Encoding
Encryption
Mathematics
Series
    

Prime Numbers

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

Enter the largest value:

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

Enter a value:

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.

Enter the start value:

Enter the end value:

4

2 + 2

6

3 + 3

8

3 + 5

10

3 + 7, 5 + 5

12

5 + 7

14

3 + 11, 7 + 7

16

3 + 13, 5 + 11

18

5 + 13, 7 + 11

20

3 + 17, 7 + 13

22

3 + 19, 5 + 17, 11 + 11

24

5 + 19, 7 + 17, 11 + 13

26

3 + 23, 7 + 19, 13 + 13

28

5 + 23, 11 + 17

30

7 + 23, 11 + 19, 13 + 17

32

3 + 29, 13 + 19

34

3 + 31, 5 + 29, 11 + 23, 17 + 17

36

5 + 31, 7 + 29, 13 + 23, 17 + 19

38

7 + 31, 19 + 19

40

3 + 37, 11 + 29, 17 + 23

42

5 + 37, 11 + 31, 13 + 29, 19 + 23

44

3 + 41, 7 + 37, 13 + 31

46

3 + 43, 5 + 41, 17 + 29, 23 + 23

48

5 + 43, 7 + 41, 11 + 37, 17 + 31, 19 + 29

50

3 + 47, 7 + 43, 13 + 37, 19 + 31

52

5 + 47, 11 + 41, 23 + 29

54

7 + 47, 11 + 43, 13 + 41, 17 + 37, 23 + 31

56

3 + 53, 13 + 43, 19 + 37

58

5 + 53, 11 + 47, 17 + 41, 29 + 29

60

7 + 53, 13 + 47, 17 + 43, 19 + 41, 23 + 37, 29 + 31

62

3 + 59, 19 + 43, 31 + 31

64

3 + 61, 5 + 59, 11 + 53, 17 + 47, 23 + 41

66

5 + 61, 7 + 59, 13 + 53, 19 + 47, 23 + 43, 29 + 37

68

7 + 61, 31 + 37

70

3 + 67, 11 + 59, 17 + 53, 23 + 47, 29 + 41

72

5 + 67, 11 + 61, 13 + 59, 19 + 53, 29 + 43, 31 + 41

74

3 + 71, 7 + 67, 13 + 61, 31 + 43, 37 + 37

76

3 + 73, 5 + 71, 17 + 59, 23 + 53, 29 + 47

78

5 + 73, 7 + 71, 11 + 67, 17 + 61, 19 + 59, 31 + 47, 37 + 41

80

7 + 73, 13 + 67, 19 + 61, 37 + 43

82

3 + 79, 11 + 71, 23 + 59, 29 + 53, 41 + 41

84

5 + 79, 11 + 73, 13 + 71, 17 + 67, 23 + 61, 31 + 53, 37 + 47, 41 + 43

86

3 + 83, 7 + 79, 13 + 73, 19 + 67, 43 + 43

88

5 + 83, 17 + 71, 29 + 59, 41 + 47

90

7 + 83, 11 + 79, 17 + 73, 19 + 71, 23 + 67, 29 + 61, 31 + 59, 37 + 53, 43 + 47

92

3 + 89, 13 + 79, 19 + 73, 31 + 61

94

5 + 89, 11 + 83, 23 + 71, 41 + 53, 47 + 47

96

7 + 89, 13 + 83, 17 + 79, 23 + 73, 29 + 67, 37 + 59, 43 + 53

98

19 + 79, 31 + 67, 37 + 61

100

3 + 97, 11 + 89, 17 + 83, 29 + 71, 41 + 59, 47 + 53

Contents Copyright 2026 Andy Abraham

Please email comments to info@mathsandcomputing.co.uk