Understanding Prime Numbers: Definition, Properties, and Python Examples
Table of Content:
Prime numbers are the numbers that have only two factors, that are, 1 and the number itself.
Consider an example of number 5, which has only two factors 1 and 5. This means it is a prime number.
Let us take another example of the number 6, which has more than two factors, i.e., 1, 2, 3, and 6. This means 6 is not a prime number.
Now, if we take the example of the number 1, we know that it has only one factor. So, it cannot be a prime number as a prime number should have exactly two factors. This means 1 is neither a prime nor a composite number, it is a unique number.
Prime numbers are the natural numbers (positive integer) greater than 1 with exactly two factors, i.e. 1 and the number itself.
Any whole number greater than 1 that is divisible only by 1 and itself, is defined as a prime number.
Prime Factor
Factors of a number that are prime numbers are called as Prime factors of that number. For example: 2 and 5 are the prime factors of 10.
2 and 3 are the prime factors of 18.
List of Prime Numbers
There are 25 prime numbers from 1 to 100. The complete list of prime numbers from 1 to 100 is given below:
| List of Numbers | Prime Numbers |
|---|---|
| Between 1 and 10 | 2, 3, 5, 7 |
| Between 11 and 20 | 11, 13, 17, 19 |
| Between 21 and 30 | 23, 29 |
| Between 31 and 40 | 31, 37 |
| Between 41 and 50 | 41, 43, 47 |
| Between 51 and 100 | 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 |
Properties of Prime Numbers
Some of the important properties of prime numbers are given below:
- A prime number is a whole number greater than 1.
- It has exactly two factors, that is, 1 and the number itself.
- There is only one even prime number, that is, 2.
- Any two prime numbers are always co-prime to each other.
- Every number can be expressed as the product of prime numbers.
- Assignment 1: C Program - Prime Numbers Between Two Integers
- Assignment 2: C Program to Check Prime and Armstrong Number
- Assignment 3: C Program - Integer as a Sum of Two Prime Numbers
- Assignment 4: C Program - Command Line Program to Check if a Number is Prime or Not
- Assignment 5: C Program - Write a program to check whether a number is a prime number or not.(Using While loop)
- Assignment 6: Write a program for printing prime numbers between 1 and 100.
- Assignment 7: Write C a program to print the prime factors of a given number using a function.
- Assignment 8: C Program to print the prime factors using recursion
- Assignment 9: Square Root of Prime Number using Command Line Argument
- Assignment 10: Check whether a given number is prime or not (using for loop)
- Assignment 11: C Program to check whether a given number is prime or not (using do-while loop)
- Assignment 12: C program to find prime factors of a number using for loop
- Assignment 13: Prime Number Program in C#
- Assignment 14: Java Program - Nth Prime Number
- Assignment 15: Java Program - Check if a Number is Prime
- Assignment 16: Java Program - Find All Prime Numbers in a Range
- Assignment 17: Java Program - Prime Factorization
- Assignment 18: Java Program - Sieve of Eratosthenes
- Assignment 19: Java Program - Sum of Prime Numbers in a Range