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
- Find sum of modulo K of first N natural number
- Find coordinates of a prime number in a Prime Spiral
- 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 largest prime factor of a number
- Find prime number K in an array such that (A[i] % K) is maximum
- Find sum of a number and its maximum prime factor
- Find Largest Special Prime which is less than or equal to a given number
- Analysis of Different Methods to find Prime Number in Python
- Find a sequence of N prime numbers whose sum is a composite number
- Find third number such that sum of all three number becomes prime
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.