C programming is prime or not

Updated on technology 2024-06-04
7 answers
  1. Anonymous users2024-02-11

    #include

    #include

    using namespace std;

    bool issushu(int longlongmax) determines whether it is prime.

    for(int j=2;j*jif(longlongmax%j==0)

    return false;

    return true;

    int main()

    int a;

    cout<<"Input:"if(issushu(a))

    cout<<"yes"return 0;

  2. Anonymous users2024-02-10

    Just look for an introductory tutorial, many books have this example, you can learn from it.

  3. Anonymous users2024-02-09

    See if they are divisible by num. If divisible, the number entered is not prime; Conversely, the input number is prime. The values tested need to be bound by the square root between 2 and num to see if they are divisible by num.

    If divisible, the number entered is not prime; Conversely, the input number is prime.

    Characteristics of prime numbersPrime numbers are also known as prime numbers. An integer is a number in a natural number greater than 1 that is not divisible by any natural number other than 1 and the integer itself. In other words, a natural number with only two positive factors (1 and itself) is prime.

    A number that is greater than 1 but is not a prime number is called a composite number. 1 and 0 are neither prime nor composite. Prime numbers play an important role in number theory.

  4. Anonymous users2024-02-08

    Objective: To determine whether a number is prime.

    # include

    int main(void)

    Functions of the for loop:

    If it is divisible, the function is jumped out by break;

    If it is not divisible until m-1, then i increments 1 to m, and i does not satisfy < m to jump out of the for loop, then i = m.

  5. Anonymous users2024-02-07

    2. Then write the logic of judging prime numbers, here first introduce a scanf function, accept the value entered by the user and store the variable, judge whether it is a prime number for the received variable, and the basis for judging is that if it can be divisible by a number in 2 to n-1, it is a prime number, otherwise it is not. Finally, just print out the results of the judgment

    3. Finally, compile and run the program, press crtl+f5 to compile, enter the prime number 17 in the pop-up command line, and the result of the program's judgment is a prime number, indicating that the logic of the program is no problem. The above is how C determines prime numbers:

  6. Anonymous users2024-02-06

    The easiest way to do this is to divide this number by a smaller integer (up to 2), and if you can't divide it, it's prime. If there is one divisible, it exits the loop, showing that it is not prime. To determine whether to divide is to determine whether the divisor * quotient is equal to the dividend.

  7. Anonymous users2024-02-05

    int main()

    printf("%d is the prime number",x);

    return 0;

    I won't write a comment.

Related questions
4 answers2024-06-04

#include

#include >>>More

7 answers2024-06-04

There are problems with your judgment, so I won't talk about the semicolon, I rewrote it, and your logic is not right, if(i%k!=0) cout< >>>More

16 answers2024-06-04

*It's just that there is something wrong with the cycle conditions, see the changes >>>More

4 answers2024-06-04

First determine whether the year is a leap year (divisible by 4) according to the number of years, and then determine which array to use: >>>More

23 answers2024-06-04

lable click event.

private void lable_click(object sender, eventargs e) >>>More