Prime Number

A number which is only divisible by 1 and itself is called prime number. Numbers 2, 3, 5, 7, 11, 13, 17, etc. are prime numbers.

  • 2 is the only even prime number.
  • It is a natural number greater than 1 and so 0 and 1 are not prime numbers.

Prime number in PHP

Example:

Here is the Program to list the first 15 prime numbers.

Output:

PHP Prime number 1

Prime Number using Form in PHP

Example:

We'll show a form, which will check whether a number is prime or not.

Output:

On entering number 12, we get the following output. It states that 12 is not a prime number.

PHP Prime number 2

On entering number 97, we get the following output. It states that 97 is a prime number.

PHP Prime number 3
Next TopicTable of Number




Latest Courses