Input: A positive integer number a.
Output: A positive integer number s.
Let s = s +
In this algorithm, the word while indicates a loops, meaning that following indented steps are repeated as long as the loop condition of a
> 0 holds. Also, note the operation a
/10 is integer division, meaning that the fractional portion of the result is simply dropped (e.g. 10/4 = 2).
(a) What is the output of the algorithm if the input is a
(b) One important characteristic of an algorithm is efficiency.
Typically, this is measured by the number of operations the algorithm performs. How many additions does this algorithm perform given the input of some positive integer a
? Express your answer as a function of a