Created
October 30, 2020 05:42
-
-
Save nineteeneightyfour1219/6838ab102a823821bdc0ae47d2e48744 to your computer and use it in GitHub Desktop.
boj4948(베르트랑공준)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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