Skip to content

is_prime

Vašek edited this page Feb 5, 2019 · 2 revisions

is_prime

This function checks whether the input number is a prime number

Syntax:

is_prime(n)
Argument Description
int n The number you want to know if it is a prime number

Returns: bool

Description:

A prime number is a number that is divisible only by itself and 1 (e.g. 2, 3, 5, 7, 11). This function returns 1 if the input number is prime, or 0 if the number isn't prime.

Example:

bool value = is_prime(25);

25 is not prime - it is divisible by 5. This function will set value to 0.

Example 2:

int value = 0;
if (is_prime(13)){
value = 1;
}

13 is prime number. This function will set value 1.

Back to number_functions

Clone this wiki locally