Poj_1284_Primitive root, poj_1284_primitive

Source: Internet
Author: User

Poj_1284_Primitive root, poj_1284_primitive
We say that integer x, 0 <x <p, is a primitive root modulo odd prime p if and only if the set {(x I mod p) | 1 <= I <= p-1} is equal to {1 ,..., p-1 }. for example, the consecutive powers of 3 modulo 7 are 3, 2, 6, 4, 5, 1, and thus 3 is a primitive root modulo 7.
Write a program which given any odd prime 3 <= p <65536 outputs the number of primitive roots modulo p.

Input

Each line of the input contains an odd prime numbers p. Input is terminated by the end-of-file seperator.

Output

For each p, print a single number that gives the number of primitive roots in a single line.

Sample Input

233179

Sample Output

10824

Method to Evaluate the original root of the modulo Prime Number:Decomposition of a prime factor, that is, a standard factorization type.



Is the original root. (For the original root of the sum, you only need to replace it)

 

Definition:Set, to make the smallest set up, called the order of the Peer Model, recorded.


Theorem:If the modulo has the original root, there is a total of original root.


Theorem:If yes, then.


Theorem:If it is a prime number, the prime number must exist in the original root, and the number of the original root of the modulo is.

 


Theorem:It is a positive integer. If the degree of the modulo is equal to, it is called an original root of the modulo.


Assume that a number is the original root for a modulo, and the result is different from each other. It can be called the original root of a modulo. In the final analysis, it is effective only when it is exponential. (Here is the prime number)

 

#include<iostream>#include<cstring>#include<cmath>#include<algorithm>#include<cstdio>#define maxn 65550using namespace std;typedef long long ll;int phi[maxn];int a[maxn];bool vis[maxn];int val[maxn];int prime[maxn],pn=0;int main(){    int i,j;    for(i=1; i<=maxn; i++)        phi[i]=i;    for(i=2; i<=maxn; i+=2)        phi[i]/=2;    for(i=3; i<=maxn; i+=2)        if(phi[i]==i)        {            for(j=i; j<=maxn; j+=i)                phi[j]=phi[j]/i*(i-1);        }    int n;    while(~scanf("%d",&n))    {        cout<<phi[n-1]<<endl;    }}

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.