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

Задача 39782. 16-30


Задача

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

F(n) = n + 10 if n < 10;
F(n) = n % 10 + G(F(n/10)), otherwise;
G(n) = n + 10 if n < 10;
G(n) = n % 10 + G(n/10), otherwise;

Determine the number of distinct values n, not exceeding 106,  for which function F(n) is a multiple of 7?
The sign / - means integer division operation.
The sign % - means the operation of calculating the remainder when dividing two integers.