osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

on a very slow function


On Mon, Oct 2, 2017 at 11:34 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
>> change it to
>>
>>       last = (last**2 + c) % N
>>       return next
>
> Better:
>
> last = (pow(last, 2, N) + (2 % N)) % N
>
> will almost certainly be faster for large values of last.

I think possibly you mean (c % N) in the middle there? Not sure but
there ought to be a reference to c somewhere.

ChrisA