#include <stdio.h>
#include <math.h>
int IsPrime(int num)
{
int i;
for(i = 2; i <= sqrt(num); i ++)
{
if(num%i == 0)
return 0;
}
return 1;
}
int main()
{
int M,N;
scanf("%d%d",&M,&N);//input the value of M and N
// printf("M=%d,N=%d",M,N);
int i;
int count_N = 0;
int prime = 2;
int prime_num[10000];
while(count_N <= N)
{
if(IsPrime(prime) == 1)
{
prime_num[count_N] = prime;
count_N ++;
}
prime ++;
}
int flag = 0;
for(i = M - 1; i <= N -1; i ++)
{
if(flag == 10)
{
printf("\n");
flag = 0;
}
printf("%d",prime_num[i]);
if(flag < 10)
{
if(flag != 9 && i != N -1)
printf(" ");
}
flag ++;
}
return 0;
}
|