# include <stdio.h>
# define no 0
# define yes 1
int main(void)
{
    long num;  //要检查的数
    long div;  //潜在的除数
    long lim;  //限制的值
    int prime;  //质数 素数

    printf("Please enter limit to values to be checked:");
    printf("Enter q t quit.\n");
     
    while (scanf("%ld",&lim) == 1 && lim > 0)
    {
        for (num = 2;num <= lim;num++)
        {
            for (div = 2,prime = yes;(div * div) <= num;div++)
                if (num % div == 0)
                    prime = no;
                if (prime == yes)
                    printf("%ld is prime.\n",num);
        }
        printf("Please enter another limit;");
        printf("Enter q to quit.\n");
    }
    return 0;
}
这是个求素数的嵌套循环 看了半天实在看不出头绪 请高手帮忙解释下