naive solution
somewhat solution for f(4)
f(4), f(10), f(157) solves but not for all
faster by adding break
First check only on first digit instead of larger range
Solved