Skip to content

Instantly share code, notes, and snippets.

@dkellycollins
Created February 27, 2014 17:23
Show Gist options
  • Save dkellycollins/9254733 to your computer and use it in GitHub Desktop.
Save dkellycollins/9254733 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
int numOfCoPrimes = 0;
for (int i = 1; i < 1225; i++)
{
int g = gdc(i, 1225);
if (g == 1)
numOfCoPrimes++;
}
Console.WriteLine(numOfCoPrimes);
}
static int gdc(int a, int b)
{
int gdc = 1;
for (int i = 2; i <= Math.Min(a, b); i++)
{
if (a % i == 0 && b % i == 0)
{
gdc = i;
}
}
return gdc;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment