# isPrime() Function & Examples

Use the isPrime() utils function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## isPrime

#### isPrime(x)

Try it yourself:

```calculio
isPrime(3)
isPrime(-2)
isPrime([2, 17, 100])
```

---

## isPrime(): test primality

**isPrime(n)** returns whether n is a prime number: an integer greater than 1 with exactly two positive divisors, 1 and itself. Thus 2, 3, and 5 are prime; 1 and 4 are not.

## Why primes matter

Primes are building blocks of integers and are important in factorization, hashing, and public-key cryptography. Use [gcd()](https://calcul.io/function/gcd/index.md) to examine shared factors, [invmod()](https://calcul.io/function/invmod/index.md) in modular arithmetic, and [mod()](https://calcul.io/function/mod/index.md) to inspect remainders.

## Input rules

Supply a finite integer. A negative number, zero, one, or fraction is not prime. Validate with [isInteger()](https://calcul.io/function/isInteger/index.md) and [isFinite()](https://calcul.io/function/isFinite/index.md) when input is external.

[All functions](https://calcul.io/functions/index.md)
