Home > Back-end > This question is a bit difficult to ah, I'm fan! Save the children!
This question is a bit difficult to ah, I'm fan! Save the children!
Time:09-26
Subject for realization of a simple function of prime number and the use of the function to determine whether a given interval integer prime Numbers, and output function, according to a row of five
Prime: only positive integer divisible by 1 and itself, is not a prime number 1, 2 is a prime number
Function interface definition:
Int IsPrime (int x);
M void PrintPrime (int, int n);
IsPrime () function, when x is a prime number return 1, otherwise it returns 0. Function PrintPrime output range within [m, n] all prime Numbers, according to a row of five output, if not a prime number in this interval, then output "does not exist within the range of the prime",
Requirement: the main function of the input of two positive integers m and n, the calling function PrintPrime output, IsPrime function calls a function PrintPrime need to decide in the interval [m, n] whether an integer is prime,
CodePudding user response:
Fans have to write one line of code you are not to come out...
CodePudding user response:
This kind of problem baidu a lot of
CodePudding user response:
Please click my blog
CodePudding user response:
For (j=n; j<=m; j++); For (I=2, isprime=true; i<=j/2; I++) { If (j % I==0) Isprime=false; } Return isprime;
Judging prime code so give it a try I don't guarantee for other plus the baidu, a lot of this subject