CEMC Banner

Problem of the Week
Problem C and Solution
Just a Little Output

Problem

Harlow has written a program. After she inputs a number into the program the number is multiplied by \(2\), then the product is divided by \(3\), then \(5\) is subtracted from the quotient. The final result is then printed.

For example, if Harlow inputs the number \(60\) into the program then following the steps outlined, the number \(60\) is first multiplied by \(2\) to obtain \(60 \times 2 = 120\). Then the product is divided by \(3\) to obtain \(120 \div 3 = 40\). Finally, \(5\) is subtracted from the quotient to obtain \(40-5=35\). The number \(35\) is then printed.

If Harlow inputs only positive integers into the program, determine the smallest possible positive output number that can be printed.

Solution

We can start by trying different input numbers, starting with \(1\) and increasing by \(1\) each time, to see if the output numbers form a pattern. The results for inputs from \(1\) to \(5\) are in the following table.

Input After Multiplying by \(2\) After Dividing by \(3\) After Subtracting \(5\)
\(1\) \(1 \times 2 =2\) \(2 \div 3 =\frac{2}{3}\) \(\frac{2}{3}-\frac{15}{3}=-\frac{13}{3}\)
\(2\) \(2 \times 2=4\) \(4 \div 3 =\frac{4}{3}\) \(\frac{4}{3}-\frac{15}{3}=-\frac{11}{3}\)
\(3\) \(3 \times 2=6\) \(6 \div 3=2\) \(2-5=-3\)
\(4\) \(4 \times 2=8\) \(8 \div 3=\frac{8}{3}\) \(\frac{8}{3}-\frac{15}{3}=-\frac{7}{3}\)
\(5\) \(5 \times 2=10\) \(10 \div 3=\frac{10}{3}\) \(\frac{10}{3}-\frac{15}{3}=-\frac{5}{3}\)

From this table we can see that when the input numbers are positive integers starting at \(1\) and increasing by \(1\) each time, the output numbers form a linear sequence that increases by \(\frac{2}{3}\) each time. We now proceed with two different solutions.

Solution 1

In this solution we continue the table until we get the first positive output value.

Input After Multiplying by \(2\) After Dividing by \(3\) After Subtracting \(5\)
\(6\) \(6 \times 2=12\) \(12 \div 3=4\) \(4-5=-1\)
\(7\) \(7 \times 2=14\) \(14 \div 3=\frac{14}{3}\) \(\frac{14}{3}-\frac{15}{3}=-\frac{1}{3}\)
\(8\) \(8 \times 2=16\) \(16 \div 3=\frac{16}{3}\) \(\frac{16}{3}-\frac{15}{3}=\frac{1}{3}\)

From the table, the first positive output number is \(\frac{1}{3}\), and happens when the input number is \(8\). Since the output numbers form an increasing sequence, we know that \(\frac{1}{3}\) is also the smallest possible positive output number.

Note that this solution worked well here because the input number for the smallest possible positive output number was fairly small. If the input number had been much larger than \(8\) then this wouldn’t have been an efficient solution.

Solution 2

This solution uses algebra to solve the problem. Let \(n\) be the input number. Following the steps in the program, we first multiply by \(2\) to obtain \(2 \times n\). We then divide by \(3\) to obtain \(\frac{2 \times n}{3}\). Finally, we subtract \(5\) from this quotient to obtain \(\frac{2 \times n}{3} -5\). Thus, when the input is \(n\), the output is \(\frac{2 \times n}{3} -5\). Since we want the output number to be positive, then \[\begin{aligned} \frac{2 \times n}{3} -5 &> 0\\ \frac{2 \times n}{3} &> 5\\ 2 \times n &> 5 \times 3\\ 2 \times n &> 15\\ n &> 15 \div 2\\ n &> 7.5 \end{aligned}\] Thus, the input number must be greater than \(7.5\). Since the input number must be an integer, it follows that the smallest input number with a positive output number is \(8\). Since the output numbers form an increasing sequence, an input of \(8\) will give the smallest possible positive output number. When the input number is \(8\), the output number is: \[\frac{2 \times 8}{3} -5 = \frac{16}{3}-5 = \frac{16}{3} - \frac{15}{3} = \frac{1}{3}\] Therefore, if the input number is a positive integer, then the smallest possible positive output number is \(\frac{1}{3}\).