PrimitiveRoot
✖
PrimitiveRoot
Details

- PrimitiveRoot[n] gives a generator for the multiplicative group of integers modulo n relatively prime to n.
- PrimitiveRoot[n] returns unevaluated if n is not 2, 4, an odd prime power, or twice an odd prime power.
- PrimitiveRoot[n,1] computes the smallest primitive root of n.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases

https://wolfram.com/xid/0d6fzaol66-iv0

The primitive root generates all integers modulo 9 that are relatively prime to 9:

https://wolfram.com/xid/0d6fzaol66-ijkmdx


https://wolfram.com/xid/0d6fzaol66-bq53j8

The smallest primitive root of 10:

https://wolfram.com/xid/0d6fzaol66-b2dajr

Scope (3)Survey of the scope of standard use cases
Find the smallest primitive root:

https://wolfram.com/xid/0d6fzaol66-jdy1nn

Find the primitive root greater than a number:

https://wolfram.com/xid/0d6fzaol66-pzdpx

PrimitiveRoot works on large integers:

https://wolfram.com/xid/0d6fzaol66-d29mhr

PrimitiveRoot automatically threads over lists:

https://wolfram.com/xid/0d6fzaol66-b1evbg

Properties & Relations (2)Properties of the function, and connections to other functions
The multiplicative order of a primitive root modulo n is EulerPhi[n]:

https://wolfram.com/xid/0d6fzaol66-vgc023


https://wolfram.com/xid/0d6fzaol66-1ueaj6

For a prime p, there exist EulerPhi[p-1] primitive roots modulo p:

https://wolfram.com/xid/0d6fzaol66-47hl3g


https://wolfram.com/xid/0d6fzaol66-h7y0pm

Possible Issues (1)Common pitfalls and unexpected behavior
PrimitiveRoot is not defined for all integers:

https://wolfram.com/xid/0d6fzaol66-584dca

Wolfram Research (2007), PrimitiveRoot, Wolfram Language function, https://reference.wolfram.com/language/ref/PrimitiveRoot.html (updated 2015).
Text
Wolfram Research (2007), PrimitiveRoot, Wolfram Language function, https://reference.wolfram.com/language/ref/PrimitiveRoot.html (updated 2015).
Wolfram Research (2007), PrimitiveRoot, Wolfram Language function, https://reference.wolfram.com/language/ref/PrimitiveRoot.html (updated 2015).
CMS
Wolfram Language. 2007. "PrimitiveRoot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/PrimitiveRoot.html.
Wolfram Language. 2007. "PrimitiveRoot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/PrimitiveRoot.html.
APA
Wolfram Language. (2007). PrimitiveRoot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PrimitiveRoot.html
Wolfram Language. (2007). PrimitiveRoot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PrimitiveRoot.html
BibTeX
@misc{reference.wolfram_2025_primitiveroot, author="Wolfram Research", title="{PrimitiveRoot}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/PrimitiveRoot.html}", note=[Accessed: 05-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_primitiveroot, organization={Wolfram Research}, title={PrimitiveRoot}, year={2015}, url={https://reference.wolfram.com/language/ref/PrimitiveRoot.html}, note=[Accessed: 05-June-2025
]}