-
-
Notifications
You must be signed in to change notification settings - Fork 19
is_prime
Vašek edited this page Feb 5, 2019
·
2 revisions
This function checks whether the input number is a prime number
is_prime(n)| Argument | Description |
|---|---|
int n |
The number you want to know if it is a prime number |
Returns: bool
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.
bool value = is_prime(25);25 is not prime - it is divisible by 5. This function will set value to 0.
int value = 0;
if (is_prime(13)){
value = 1;
}13 is prime number. This function will set value 1.
Back to number_functions