Perhaps Python extended precision numbers are represented in base 2? That would explain why (2^k)^n is fast but 3^n is slow.
In J: m=: 10^10x timer=: 6!:2 NB. 500 Mhz Pentium III timer '2 m&|@^ 7830457' 0.000684724 timer '3 m&|@^ 7830457' 0.000708749 timer '5 m&|@^ 7830457' 0.000741994 timer '7 m&|@^ 7830457' 0.00073026 timer '11 m&|@^ 7830457' 0.000770768 timer '2 m&|@^ 10^100x' 0.00848516 timer '3 m&|@^ 10^100x' 0.00841755 timer '5 m&|@^ 10^100x' 0.00863182 timer '7 m&|@^ 10^100x' 0.0084751 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. ----- Original Message ----- From: "bill lam" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Monday, March 06, 2006 2:49 AM Subject: Re: [Jprogramming] If Maple can, why can't J? I also downloaded Python (ver. 2.4.2 window), in command mode when I typed prime = (28433 * (2 ** 7830457) + 1) it finished in about one second. I timed it using handheld stopwatch. very fast for prime = (28433 * (4 ** 7830457) + 1) prime = (28433 * (8 ** 7830457) + 1) prime = (28433 * (16 ** 7830457) + 1) but it take forever to compute prime = (28433 * (3 ** 7830457) + 1) apparently, there is some clever method to calculate 2&^ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
