work_function controls which factoring function should be used.