hermann on Wed, 21 Jun 2023 13:07:29 +0200


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

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


Pari userguide states that integers must be in absolute value less than 2^536870815 on 64bit systems.

My n has only 79 decimal digits, but I assume the following error is because of said integer size restriction:

? #digits(n)
%152 = 79
? Mod(2^(n+1),n)
  ***   at top-level: Mod(2^(n+1),n)
  ***                      ^---------
  *** _^_: overflow in lg().
  ***   Break loop: type 'break' to go back to GP prompt
break>

So it seems "Mod()" computes LHS value first before applying RHS modulo.
Is that true?


How can I compute what is easy to do with Python pow() in PARI/GP?

len(str(n))
79
pow(2, n+1, n)
5777588243495850683460451056129556465560362083125689614529910382255697025456333



Regards,

Hermann.