Roger Hui wrote:
> Perhaps Python extended precision numbers are represented
> in base 2?  That would explain why (2^k)^n is fast but 3^n
> is slow.
>
>

>From the Python documentation:

Long integers
    These represent numbers in an unlimited range, subject to available
(virtual) memory only. For the purpose of shift and mask operations, a
binary representation is assumed, and negative numbers are represented
in a variant of 2's complement which gives the illusion of an infinite
string of sign bits extending to the left.

>
> How do you compute the last 10 decimal digits of 2^10^100x
> in Python?  The direct phrase
>
>    x = (2 ** (10 ** 100)) % (10 ** 10)
>
> probably will not work.
>
>

It's been running for over 30 minutes here.

Best wishes,

John


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to