on a very slow function
On Tue, 3 Oct 2017 04:23 am, Ian Kelly wrote:
>> py> (2**75 + 7) % 12 # Expected value.
>> py> ((2**75) % 12 + (7 % 12)) % 12 # Correct.
>> py> (2**75) % 12 + (7 % 12) # Incorrect.
> No, only the final one is necessary. Modding the result of the
> exponentiation might be useful for performance, but if c is expected
> to be small then it may be pointless to mod that as well.
> py> ((2**75) % 12 + 7) % 12 # Still correct.
Its been years since I've had to tackle modulo arithmetic, but the more I
think about it, the more I think you are right.
?Cheer up,? they said, ?things could be worse.? So I cheered up, and sure
enough, things got worse.