Skip to content

PHP Program to Check Prime Number

Last updated on November 20, 2017

In this tutorial, you will learn what is a prime number and how to check whether the given number is a prime number or not using PHP.

php program check prime number

What is Prime Number?

A prime number is a natural number which is exactly two positive divisors, 1 and itself. For example, take number 13, its a prime number because it has only two positive divisors.

How to Check Prime Number with PHP?

Below is the simple PHP program to find a given number is prime or not using for loop and if..else control structure.


Output

 This is a Prime Number. 
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments