If
x = (2 ** (10 ** 100)) % (10 ** 10)
has been running for over 30 minutes then it probably will
run for a while longer. If it's been running for over 30
minutes it's probably doing the computation directly without
any kind of cleverness, which means computing a number with
3e99 decimal digits or 10^100 bits.
With a small amount of cleverness:
m=: 10^10x
timer=: 6!:2 NB. 500 Mhz Pentium III
timer '2 m&|@^ 10^100x'
0.00848516
That is, 8.5 milliseconds.
----- Original Message -----
From: "John Randall" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Monday, March 06, 2006 10:00 AM
Subject: Re: [Jprogramming] If Maple can, why can't J?
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.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm