# Primitive root modulo n (primitive_root)

A primitive root of a prime: a number whose powers cover all the nonzero residues.

## How to write it

### primitive_root(p)

**p**

A prime. Takes a whole number.

## Examples

- $\displaystyle \operatorname{primitive\_root}(7) = 3$

  `primitive_root(7)`

  In the solver, `primitive_root(7)` gives `3`.

  [Open in the solver](https://hilberon.com/?q=primitive_root%287%29)

## Related functions

- [solve_congruence](https://hilberon.com/library/solve_congruence)

  Solve a congruence for a variable.
- [prime_pi](https://hilberon.com/library/prime_pi)

  How many primes are at most a number.
- [squares_r](https://hilberon.com/library/squares_r)

  How many ways a whole number is a sum of a given count of squares, counting order and signs.
- [prime_omega](https://hilberon.com/library/prime_omega)

  How many primes divide a whole number, counted with multiplicity.
- [stirling_s1](https://hilberon.com/library/stirling_s1)

  Stirling number of the first kind, with sign.
- [prime_nu](https://hilberon.com/library/prime_nu)

  How many distinct primes divide a whole number.

---
Source: https://hilberon.com/library/primitive_root
