Consider the following algorithm: The input will be any positive integer n. grea
ID: 1942322 • Letter: C
Question
Consider the following algorithm: The input will be any positive integer n. greaterthan 1.
step 1. if n/2 is an integer, then output yes! and stop
step 2 output no! and stop
(a) List the output for input n = 12. Then for input n = 13. Then for 14.
(b) Describe in words what this algorithm does. In other words, what problem
does this algorithm solve? Your answer should be a single simple sentence
such as When the algorithm operates on input n, the output is the square of n.
Explanation / Answer
(a) n = 12: n/2 = 6 -> Yes! n = 13: n/2 = 6.5 -> No! n = 14: n/2 = 7 -> Yes! (b) When the algorithm operates on input n, the output says whether or not the input n is an even number.