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
- 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 all the prime numbers of given number of digits
- Find sum of a number and its maximum prime factor
- Find prime number K in an array such that (A[i] % K) is maximum
- Find largest prime factor of a number
- Analysis of Different Methods to find Prime Number in Python
- Find a sequence of N prime numbers whose sum is a composite number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.