Skip to content

Instantly share code, notes, and snippets.

@nineteeneightyfour1219
Created October 30, 2020 05:42
Show Gist options
  • Save nineteeneightyfour1219/6838ab102a823821bdc0ae47d2e48744 to your computer and use it in GitHub Desktop.
Save nineteeneightyfour1219/6838ab102a823821bdc0ae47d2e48744 to your computer and use it in GitHub Desktop.
boj4948(베르트랑공준)
#include<stdio.h>
#include<math.h>
int odd(int x)
{
int j,check;
int sum=0;
for (int i=x+1;i<=2*x;i++)
{
check=0;
j=sqrt(i);
for (int f=2;f<=j;f++)
{
if (i%f==0)
{
check=1;
break;
}
else continue;
}
if (check==0) sum++;
}
return sum;
}
int main()
{
int k;
while (scanf("%d",&k) && k!=0)
{
printf("%d\n",odd(k));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment