Skip to content

Instantly share code, notes, and snippets.

@steinelu
Created January 13, 2019 20:15
Show Gist options
  • Save steinelu/ed7d0f359b4cde54240df35c6bb46468 to your computer and use it in GitHub Desktop.
Save steinelu/ed7d0f359b4cde54240df35c6bb46468 to your computer and use it in GitHub Desktop.
int ggt(int m, int n)
{
if(!m)
return n;
return ggt(n%m , m);
}
int phi(int n)
{
int cnt = 0;
for(int i = 1; i < n; i++)
{
if(ggt(i, n) == 1)
{
cnt++;
//printf("%d\n", i);
}
}
return cnt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment