Home > Back-end >  Why run result has been to 0, the great spirit guide
Why run result has been to 0, the great spirit guide

Time:12-03

Define isprime (n) function is used to determine whether an integer n is prime Numbers; In the main functional
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 wrong

CodePudding user response:

Ah? It should be how to use

CodePudding 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:

reference 1st floor yshuise response:
printf with wrong
?

CodePudding user response:

reference 3/f, 5250 response:
first of all, the title of the request you judge the value of the k2 + k + 41 is a prime number while you figure out whether - 39 ~ 40 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;
}
see understand, thank you
  • Related