Answer
See explanation
Work Step by Step
The above function checks for all integer between 1 to n and check if that is a factor of n. If none of the number is found a factor of n then n must be prime.
Algorithm Steps
Input the positive integer N
If $N\leq 1$, then
Output “not prime” and stop
Set a variable flag = 0 (to track if a factor is found)
For each integer i from 2 to N ÷ 2 (inclusive), do
a. If $N$ mod $𝑖=0$, then
i. Output “not prime”
ii. Output the message “Factor: i”
iii. Set flag = 1
iv. Stop the loop
If after the loop flag = 0, then
Output “prime”