Description of the meaning of the question: Given an n, find the number of 1-n co-prime numbers.
#include<cstdio> #include<cmath> using namespace std; int res[100000]; int main(){ int n;scanf("%d",&n); int ans=n; int tot = 0; for(int i=2;i*i<n;i++){ if (n% i == 0) res [++ tot] = i; while(n%i==0)n/=i; } if(n>1)res[++tot]=n; for(int i=1;i<=tot;i++){ ans=ans-ans/res[i]; } printf("%d\n",ans); return 0; }