Home > Back-end >  C language compiler, as simple as possible, a great god advice please
C language compiler, as simple as possible, a great god advice please

Time:09-26

If the product of two consecutive natural number minus 1 is a prime number, said the two natural number as friend to continuously, the prime friends called prime example: 2 * 3-1=5, 2 and 3 are therefore friend pairs, 5 is prime, friend please print out the [40119] between friends and all the prime Numbers for,

CodePudding user response:

Direct write debugging
Judge prime
 
Int=2 aa, aaa=20; While (aaa * aa<=119) if (judgment primes (aa) * aaa - 1) cout

CodePudding user response:

For beginners to judge prime Numbers are generally use (n & gt; A) some (n/2 & gt; Using kf=a)=SQRT (n); (kf & gt;=a), obviously, of course, in actual use kf=SQRT (n) is good, should be adopted, and is a senior figure out whether prime number in step 2, instead of calculating the prime Numbers involved,

CodePudding user response:

# include & lt; stdio.h>
Int prime (int x) {
If (x & lt; 2) return 0;
for(int i=2; iIf I==0) (x % return 0;
}
return 1;
}
Int main (void)
{
For (int I=40; i<120; I++) {
For (int j=I + 1; j<120; J++) {
If (prime (I * j - 1)) {
Printf (" % d % d \ n ", I, j);
}
}
}
return 0;
}

CodePudding user response:

And ends here, said the ends are wrong: why don't you say it's wrong here? It quickly! Such a good chance,

CodePudding user response:

reference 1/f, the wise know already should good karma response:
don't write directly debugging
Judge prime
 
Int=2 aa, aaa=20; While (aaa * aa<=119) if (judgment primes (aa) * aaa - 1) cout
your cashout
Ends function is written to a '\ 0'
Is to give an abandoned facilities design parameter
Not to use cout
Don't be trapped by the misleading half a bucket of water
misleadingTo the output space is writing space

CodePudding user response:

reference 1/f, the wise know already should good karma response:
don't write directly debugging
Judge prime
 
Int=2 aa, aaa=20; While (aaa * aa<=119) if (judgment primes (aa) * aaa - 1) cout
by the way, this code is written completely wrong
2 aa start and completely the same?
Other logic without looking at the wrong for sure
  • Related