gives a primitive root of n.
PrimitiveRoot[n,k]
gives the smallest primitive root of n greater than or equal to k.


PrimitiveRoot
gives a primitive root of n.
PrimitiveRoot[n,k]
gives the smallest primitive root of n greater than or equal to k.
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 all close allBasic Examples (2)
Scope (3)
Find the smallest primitive root:
Find the primitive root greater than a number:
PrimitiveRoot works on large integers:
PrimitiveRoot automatically threads over lists:
Properties & Relations (2)
Possible Issues (1)
PrimitiveRoot is not defined for all integers:
See Also
PrimitiveRootList MultiplicativeOrder EulerPhi CarmichaelLambda PowerMod DirichletCharacter
Function Repository: NumberTheoreticTransform
Tech Notes
Related Guides
Text
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.
APA
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: 13-August-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: 13-August-2025]}