# Think of a Number/Examples/Bachet/1

## Classic Problem

A person chooses secretly a number, and trebles it, telling you whether the product is odd or even.
If it is even, he takes half of it,
or if it is odd, he adds one and then takes one half.
Next he multiplies the result by $3$,
and tells you how many times $9$ will divide into the answer, ignoring the remainder.
The number he chose is -- what?

## Solution

Let $n$ be the number given at the end.

If $n$ is stated as being even, then the number originally chosen was $2 n$.

If $n$ is stated as being odd, then the number originally chosen was $2 n + 1$.

## Proof

Let $x$ be the number chosen.

Let $x$ be either $2 n$ or $2 n + 1$, depending on whether it is odd or even.

If $x$ is even, the successive operations do the following:

$2 n \to 6 n \to 3 n \to 9 n \to n$

If $x$ is odd, the successive operations do the following:

$2 n + 1 \to 6 n + 3 \to 6 n + 4 \to 3 n + 2 = 9 n + 6 \to n$

$\blacksquare$