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: 3590725 • 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 a 5 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

As mentioned in the question, writing only algorithm for the above problem.

Pseudo code:

function primeNum(int N) :

if N = 0 or N = 1

    print N is not considered prime, enter different number

if N = 2

    print N is prime

    return true

if N/2 = 0 then

    print composite number

   return false

for i from 3 to N/2

    if i is prime then

        if N/i = 0

            print composite number

         return false

print N is prime

return true

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