Home > Back-end >  A prime number and (C)
A prime number and (C)

Time:06-10

Given a positive integer m, how to evaluate more than 5 minimum prime Numbers and m, 4 such as input, the prime Numbers greater than 4 is 5,7,11,13,17 and 53 respectively, which m is less than 2000000000,

CodePudding user response:

What a great god help just learn C language primary school brother ah

CodePudding user response:

Have a while loop, loop m++, having a variable records to find the number of prime Numbers, exit to five, sum back to or added can be directly to find

CodePudding user response:

 # include 
#include


Int isprime (int num)
{
Int I, rt.

Rt=(int) SQRT (num);

For (I=2; i If (num % I==0)
return 0;
return 1;
}

Int main ()
{
int m, n;
Int CNT=0, TMP, I;

The scanf (" % d % d ", & amp; M, & amp; N);

If (m & gt; N) {
TMP=m;
M=n;
N=TMP;
}

For (I=m; i <=n; I++) {
{if (isprime (I))
Printf (" % d \ t ", I);
Cnt++;
If (% CNT==0, 10)
Putchar (10);
}
}

return 0;
}


On the basis of the change

CodePudding user response:

Because the bigger the sparse of prime number 2 billion is close to a maximum of int (32-bit), therefore, should use unsigned int, or 64 - bit machine with int,

CodePudding user response:

In essence is how to find prime Numbers

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related