Number of calls to this function, judge the integer k values range between - 39 ~ 40,
K2 + + 41 k value is prime Numbers; If so, then the output of k and corresponding expression
The value of the type k2 + k + 41 why run result has been to 0, the great god guide
CodePudding user response:
Printf with wrongCodePudding user response:
Ah? It should be how to useCodePudding user response:
First of all, the title of the request you judge k2 + + 41 k value is prime and you in the judgment - 39 ~ 40 is prime Numbers you have a problem that the answer is yes!Secondly you isprime function is prime is defined as what? Besides 1 and itself being indivisible that is to say the number could not be divided exactly by the all Numbers in 2 ~ n - 1 is prime
And what do you mean by the as long as one of the 2 ~ n - 1 cannot be divided exactly by even a prime number? 15 is not a prime example but your function 15% 2=1 so 15 is the prime number do you think of?
If (I) n %==0
return 0;
The else
Return 1
The following code for reference:
# include & lt; stdio.h>
Int isprime (int n)
{
If (n & lt; 2)
return 0;
For (int I=2; I & lt; n; I++)
{
If I==0) (n % {
return 0;
}
}
return 1;
}
Int main ()
{
Int k, n;
For (k=- 39; K & lt;=4; K++)
{
N=k * 41 k +, k +;
If (isprime (n))
{
Printf (" k=% d * 41 k +, k + k=% d \ n ", k, n);
}
}
return 0;
}
CodePudding user response: