问题遇到的现象和发生背景
每一个数都会显示为素数
问题相关代码,请勿粘贴截图
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int a,b,i,j,k,c;
scanf("%d %d",&a,&b);
i = a;
j = 2;
k = 2;
c = 0;
while(a<=i && i<=b){
while(j<=i){
if(i%j==0){
break;
}else{
k++;
j++;
}
}
if(k==i){
c++;
printf("%d是素数 %d个",i,c);
}
i++;
}
return 0;
}