Oihana PHP

isPrime.php

Table of Contents

Functions

isPrime()  : bool
Tells whether an integer is a prime number.

Functions

isPrime()

Tells whether an integer is a prime number.

isPrime(int $n) : bool

Any integer lower than 2 is not prime. The test uses 6k ± 1 trial division up to √n.

Parameters
$n : int

The integer to test.

Tags
example
use function oihana\core\maths\isPrime;

isPrime( 2 )  ; // true
isPrime( 17 ) ; // true
isPrime( 25 ) ; // false
isPrime( 1 )  ; // false
author

Marc Alcaraz (ekameleon)

since
1.0.9
Return values
bool

true if $n is prime, false otherwise.

On this page

Search results