Find the fax machine's four-digit access code Y, where
f(f(f(Y))) = 60097.
Find the fax machine's extension number Z, where
f(f(Z)) = 1.
Definitions:
f(x) = 3[E(x)]3 - x
E(x) = number of letters, when x is written out in American English
(Note: letters does not include spaces or punctuation.)
The solution requires the inverse of f(x). E(x) and f(x) cannot be inverted analytically, but f(x) can be inverted with a simple search routine based on E(x).
E(x)
E(x) is trivial to implement as a recursive function using lookup tables with the number of
letters in the numbers (1-19) and (20-90 by 10), and the number of letters in "hundred",
"thousand", "million", etc.
Search
Since E(x) is undefined for negative numbers, negative values of f(x) can be ignored.
When (x > 478878), one can show that (f(x) < 0). The proof is straightforward,
if you use 10log10(x) as an upper bound for E(x).
Define F to be the value of f(x) to invert.
The search routine tests at most 54 pairs of positive integers (Etrial, xtrial),
which are related by
xtrial = 3(Etrial)3 - F
where the range of Etrial is given by
(F/3)1/3 < Etrial < (478878 / 3)1/3 ---
Note: ceil[(478878 / 3)1/3] = 55.
Finally, if (E(xtrial) = = Etrial),
then (f(xtrial) = = F).
Results
The numerical results are
f -1(f -1(f -1(60097))) =
(2465, 224561, 244511, 320735, 363959)
and
f -1(f -1(1)) = (6808, 387583).
Therefore, Y = 2465 and Z = 6808.