Skip to content

Instantly share code, notes, and snippets.

@shoya140
Created October 2, 2012 00:08
Show Gist options
  • Save shoya140/3815335 to your computer and use it in GitHub Desktop.
Save shoya140/3815335 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(void){
int i, j, k;
int count = 0;
int max = 1000000;
for (i = 2; i <= max; i++) {
for (j = 1; j < i; j++) {
int flag = 1;
for (k = 1; k <= j; k++) {
if(k != 1 && i % k == 0 && j % k == 0){
flag = 0;
break;
}
}
if(flag == 1){
count ++;
}
}
}
printf ("The answer is %d \n",count);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment