Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A prime number can be divided, without a remainder, only by itself and by 1 . 4.

ID: 3590697 • Letter: A

Question

A prime number can be divided, without a remainder, only by itself and by 1 . 4. For example, 17 can be divided only by 17 and by 1 Some facts: . The only even prime number is 2. All other even numbers can be divided by 2. .If the sum of a number's digits is a multiple of 3, that number can be divided by 3. No prime number greater than 5 ends in a 5. Any number greater than 5 that ends in a5 can be divided by 5. Zero and 1 are not considered prime numbers. Except for 0 and 1, a number is either a prime number or a composite number. A composite number is defined as any number, greater than 1, that is not prime. . To prove whether a number is a prime number, first try dividing it by 2, and see if you get a whole number. If you do, it can't be a prime number. If you don't get a whole number, next try dividing it by prime numbers: 3, 5, 7, 11 (9 is divisible by 3) and so on.. You are to write an algorithm (Pseudocode) to solve the above problem.

Explanation / Answer

BEGIN:

    n = ask user to enter the number

   

    if n is less than 2

        n is not a prime number

    else if n == 2

        n is prime number

    else if n is a multiple of 2

        n is not a prime number

    else

    {

        flag = True

        for i in range 3 to n with increment of 2 after each step

        {

            if n is divisible by i

            {

                flag = False

                break out of loop

            }

        }

        if flag == True

            n is prime number

        else

            n is not a prime number

    }

END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote