Finished answer (Python)
@masterofthetiger@theres.life @zingbretsen
That works. Simpler and much more elegant looking code than my craziness. I am not sure about the relative efficiency between yours and mine, I think you might have more multiplications but you also solve the side case of "don't use division"