Add a modulus argument to math.prod

The 3-arg pow(x,y,z) is a very different operation from pow(x,y), is not defined for anything like the same kinds of inputs and has a weird ternary dispatch that doesn’t generally work. It doesn’t help anything to put these two operations in the same function with an optional argument that completely changes the behaviour.

There is a use in having functions like inv_mod(x,m), pow_mod(x,n,m), sqrt_mod(x,m) etc but they should be distinct functions. Following that naming scheme you would even want div_mod(x,y,m) but meaning something different from divmod so that name clash would be confusing.

It is for reasonable inputs and was intended to be a simple demonstration. A pow_mod function has a little more complexity to it but prod_mod is not more complicated than the obvious loop. If you actually have a use for this function it will be for mod > 1 but feel free to handle other cases for completeness if you want.