Олимпиадный тренинг

Задача 39749. 16-14


Задача

Темы: ЕГЭ
The algorithm for calculating the value of the function F(n), where n – natural number, given by the following relations:

F(0) = 12;
F(n) = 1 + f(n/3)
if n > 0, and the number n is a multiple of 3;
F(n) = 1 + f(n/15) otherwise.

Determine how many different values ​​the F(n) function takes on the segment [1, 1000000]?
The sign / - means the operation of integer division.