# include <stdio.h>
# include <stdlib.h>
int main(void)
{
int a,b,count,k=0;
for(int m=0;m<=2;m++){
scanf("%d%d",&a,&b);
if (a > b) {printf("0\n"); continue;}
else if(b-a<=1000){
for(int i=a;i<=b;i++){
for(int j=2;j<i;j++){
if(i%j==0){
count++;}
}
if(count==0){
k++;}
count=0;
if(i==1){
k-=1;}
}
printf("%d\n",k);
k=0;
}
}
}
求解!!!!
# include
# includeint main(void)
{
int a,b,count,k=0;
for(int m=0;m<=2;m++){
scanf("%d%d",&a,&b);
if (a > b) {printf("0\n"); continue;}
else if(b-a<=1000){
for(int i=a;i<=b;i++){
for(int j=2;j
if(i%j==0){
count++;}
}
if(count==0){
k++;}
count=0;
if(i==1){
k-=1;}
}
printf("%d\n",k);
k=0;
}
}
}求解!!!!
要說電神 肯定是我瑞1奇了 for(int j=2;j<i;j++)跑太多 應該跑到sqrt(i)就好了