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

Задача 38972. 16-01


Задача

Темы: ЕГЭ
The algorithm for calculating the value of the function F(n), where n – natural number, given by the following relations:
F(n) = n * n if n <= 1;
F(n) = F(n-2) + F(n/3) if n > 1 and n is a multiple of 3 but not a multiple of 2;
F(n) = F(n/2) + F(n-3) if n > 1 and n is a multiple of 2 but not a multiple of 3;
F(n) = F(n/2) + F(n/3) if n > 1 and n is a multiple of 2 and a multiple of 3;
F(n) = F(n-1) if n > 1 and n is neither a multiple of 2 nor a multiple of 3.

Find the minimum n value such that F(n) = 104.