f(4), f(10), f(157) solves but not for all
faster by adding break