COMC 2019 C Problem 1

The function f is defined on the natural numbers 1,2,3, \ldots by f(1)=1 and

f(n)= \begin{cases}f\left(\frac{n}{10}\right) & \text { if } 10 \mid n, \\ f(n-1)+1 & \text { otherwise.}\end{cases}

Note: The notation b \mid a means integer number a is divisible by integer number b.

(a) Calculate f(2019).

(b) Determine the maximum value of f(n) for n \leq 2019.

(c) A new function g is defined by g(1)=1 and

g(n)= \begin{cases}g\left(\frac{n}{3}\right) & \text { if } 3 \mid n, \\ g(n-1)+1 & \text { otherwise. }\end{cases}

Determine the maximum value of g(n) for n \leq 100.