Isn't `factor` guaranteed to return a prime in `f`? If not, I think it should be.