Javatpoint Logo
Javatpoint Logo

Prime Number in Discrete Mathematics

Overview

An integer p > 1 will be known as the prime or prime number if and only if 1 and p are the only positive divisor of p. In simple term, any number will be known as prime number if it is divided only by 1 and itself. There is also a term known as composite that will occur if an integer q > 1 is not prime. That means if a number is divided by any other number, then it will be known as composite. In other word we can say that if a number is not prime then it will be composite.

For example:

The integers 4, 6, 8, 9 are called composite, and the integers 2, 3, 5, 7, and 11 are called the prime numbers.

Theorem 1:

An integer p > 1 will be known as a prime if for all integers x and y, p divides xy. This statement means that for prime number, p either divides x or y.

Theorem 2:

Every integer n > = 2 must contains a prime factor.

Theorem 3:

Suppose composite integer is shown by n. In this case, n must have a prime factor that will not exceed √n.

Examples of prime numbers are described as follows:

Example 1:

In this example, we have two integers, and we have to determine which one is prime. The first integer is 293, and the second integer is 9823.

Solution:

First, we will find out all the primes p in such a way that p2 <= 293. All of these primes are 2, 3, 5, 7, 11, 13, and 17. Now, 293 is not divided by any of these primes. So we can say that 293 is prime.

Now we will find out primes p in such a way that p2 <= 9823. All of these primes are 2, 3, 5, 7, 11, 13, 17, etc. Now, 9823 is not divided by any of 2, 3, 5, 7, but 11 divides 9823. So we can say that 9823 is not a prime.

Example 2:

In this example, we will assume n as a positive integer in such a way that n2 - 1 is prime. Here we have to find out the integer n.

Here n2 - 1 can be written as n2 - 1 = (n - 1) (n2 + n -+1). This is because n2 - 1 is prime, either (n2 + n -+1) = 1 or (n - 1) = 1. So now we know that n>=1 that why n2 + n + 1 > 1, i.e., n2 + n + 1 != 1. Thus, we must have n - 1 = 1. This statement indicate that n = 2.

Example 3:

In this example, we will assume p as a prime integer in such a way that gcd (a, p3) = p and gcd (b, p4) = p. Here we have to find out the gcd (ab, p7).

Solution:

To solve this, we will take the given condition gcd (a, p3) = p. Here, p | a, and p2 | a. (There will be contradiction if p2 | a, then gcd (a, p3) = p2 > p). Now we can write 'a' in the form of a product of prime powers. This is because p | a and p2 | a. This statement specifies that p appears in the form of a factor in the prime factorization of 'a', but pk will not appear in that prime factorization of 'a' because k>=2. Same as gcd (b, p4) = p, which indicates that p | b, and p2 | b. Same as described before, this statement specifies that p appears in the form of a factor in the prime factorization of 'a', but pk will not appear in the form of prime factorization of 'a' because k>=2. It now follows that p2 | ab, and p3 | ab. In conclusion, we can say that gcd (b, p7) = p2.

Primality Test Algorithm

Example:

In this example, we are going to make the algorithm more efficient, 36 =

Modified Algorithm

Algorithm to find Prime Numbers

The sieve of Eratosthenes is a type of ancient algorithm which is used in mathematics to determine all prime numbers up to any amount of giving length. The input and output of Sieve of Eratosthenes are described as follows:

Input: an integer n > 1. 
Output: It will generate all prime numbers from 2 through n. 

Here we will assume an array A of Boolean values, which is indexed with the help of integers 2 to n, initially all set to true. 
 
for i = 2, 3, 4, ....., not exceeding √n do
   if A [i] is true
      for j = i2, i2 + i, i2 + 2i, i2 + 3i, ......, not exceeding n do
          A[j] := false

return all i such that A[i] is true. 






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA