I'll retry the python version to see if I can make it work, but:

Something in the variable conversion caused the basic modulo case to fail("Fixnum#modulo returns the modulus obtained from dividing self by the given argument"). Also, I could not get the ZeroDivisionError to raise properly.

I pulled this formula from: https://github.com/topazproject/topaz/blob/879e92bef83cf9d28f0b396aa90e8780c6bd5164/lib-topaz/numeric.rb#L27-L30