Find the ten largest sets of twin primes c within 10 million

Updated on society 2024-02-08
8 answers
  1. Anonymous users2024-02-05

    What does twin primes mean?

  2. Anonymous users2024-02-04

    If both n and n+2 are primes, then these two numbers are twin primes.

  3. Anonymous users2024-02-03

    #include

    using namespace std;

    Twin primes: Pairs of prime numbers that differ by 2.

    bool prim(int m) determines whether a number is prime {if(m<2).

    return false;

    else if(m==2)

    return true;

    elsefor(int i=2;i=3;i--)int j=i-2;

    if(prim(i)&&prim(j))

    cout<

  4. Anonymous users2024-02-02

    Landlord, this program of yours has a problem with grammar, and the logic problem is even more serious. Frankly, it can't be changed.

    In this case, you should write a function to determine whether an integer is prime, and then loop it in the main function. The procedure is simple and easy to understand.

    #include

    #include

    using namespace std;

    bool isprime(int n)

    return true;

    int main()}

  5. Anonymous users2024-02-01

    Replacing the k in the two for loops with a will make it faster.

    It is advisable to find all the prime numbers of 0 k first, and then pick the twin primes from the primes.

    while(a"

  6. Anonymous users2024-01-31

    If is inside the for loop, and there is no if structure on the outside, so using else will cause an error, and the system will not find an if that matches else

  7. Anonymous users2024-01-30

    Truth be told, there are so many mistakes.

    Main error: 1 if followed by ().

    2 One sentence is finished; It can't be used,

    #include

    #include

    using namespace std;

    int sushu(int n);

    int main(void)

    return 1;

    int sushu(int n)

    return 1;

    To find a prime number (prime number), you only need to find whether it is divisible by a number of 2 to its square, and if there is a number that is divisible, it is not a prime number.

    Otherwise prime.

    j in main can be replaced by i+2.

    Finding the prime starts from 2 and 1 does not count to the maximum value -2 that is sought

    I don't understand what the variable score in sushu does.

  8. Anonymous users2024-01-29

    If should be followed by the condition in parentheses, right?

Related questions
34 answers2024-02-08

What if you have 10 million? It's not easy to make money, it's easy to spend! You need to have a lifetime of knowledge to go to graduate school, not only do you have endless money, but you can also have a lifetime of knowledge! >>>More