Given a prime . The task is to count all the primitive roots of .
A primitive root is an integer x (1 <= x < p) such that none of the integers x – 1, x2 – 1, …., xp – 2 – 1 are divisible by but xp – 1 – 1 is divisible by .
Input: P = 3
The only primitive root modulo 3 is 2.
Input: P = 5
Primitive roots modulo 5 are 2 and 3.
Approach: There is always at least one primitive root for all primes. So, using Eulers totient function we can say that f(p-1) is the required answer where f(n) is euler totient function.
Below is the implementation of the above approach:
- Primitive root of a prime number n modulo n
- Number of factors of very large number N modulo M where M is any prime number
- Find sum of modulo K of first N natural number
- Find coordinates of a prime number in a Prime Spiral
- Find the quadratic equation from the given roots
- Program to find the Roots of Quadratic equation
- Seeds (Or Seed Roots) of a number
- Given a number x , find y such that x*y + 1 is not a prime
- Program to find the Nth Prime Number
- Program to find the next prime number
- Find sum of a number and its maximum prime factor
- Find largest prime factor of a number
- Find all the prime numbers of given number of digits
- Find prime number K in an array such that (A[i] % K) is maximum
- Analysis of Different Methods to find Prime Number in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.