Andreas Enge on Wed, 21 Jun 2023 13:11:07 +0200


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

Re: How to compute "Mod(2^(n+1), n)" for very big n?


Am Wed, Jun 21, 2023 at 01:02:48PM +0200 schrieb hermann@stamm-wilbrandt.de:
> ? Mod(2^(n+1),n)

Do it the other way round:
   Mod(2,n)^(n+1).
This way, exponentiation happens directly in Z/nZ (by successive squaring
and multiplying, each followed by a reduction modulo n), instead of trying
to compute integers that may not fit into the universe.

Andreas