Prime Number

Rumman Ansari   Software Engineer   2023-01-19   450 Share
☰ Table of Contents

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.

5 is 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.

6 is not 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.

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.

Check whether a given number is prime or not?

Write a C program to check whether a given number is a prime number or not.(Using While loop)
Write a C Program to check whether a given number is prime or not (using do-while loop)
Write a Check whether a given number is prime or not (using for loop)
Integer as a Sum of Two Prime Numbers

Prime numbers between a range

Write a program for printing prime numbers between 1 and 100.

Command Line Program

Command Line Program to Check if a Number is Prime or Not
Square Root of Prime Number using Command Line Argument

Prime Factor

C Program to find prime factors of a number using for loop
Write C a program to print the prime factors of a given number using a function.

C# code for Prime Factor

Prime Number Program in C# Programming Language