Ummmm,
The time for j to calculate/assign e607 is only 0.00019% of the
total time on my machine.... What I said was that q: took 99% of the
total time - that is still true whether or not you define e607 ahead
of time. Your quest would be to find a faster way to determine e607
to be prime, hence not a perfect power.
You can time j expressions using 6!:2 e.g.
0j8 ": 6!:2 'e607 =: <: 2x ^ 607' NB. cpu time in seconds
0.00010900
and not have to say "I haven't really timed it."
At 12:53 -0800 2009/06/08, [email protected] wrote:
>e607 =: <: 2x ^ 607 NB. define e607 to eliminate its time
>overhead
>
>pp0=: *./@(0&<@#, 2&<:, 1 < +./)@(#/....@q: ::0:"0)
>
>pp0 e607
>
>takes about the same time as
>
># q: e607
>
>
>----- Original Message Follows -----
>From: Joey K Tuttle <[email protected]>
>To: Programming forum <[email protected]>
>Subject: Re: [Jprogramming] perfect power???
>Date: Mon, 8 Jun 2009 10:56:04 -0700
>
>>Only a silly 1% longer - 99% of the time is taken by q:
>>determining that <:2x^607 is a prime... (I'm impressed
>>that it does :)
>>
>>And only one segmentation fault in poking at it... :(
>>
>>
>>At 09:38 -0800 2009/06/08, [email protected]
>>>wrote: Thanks for the help.
>>>
>>>I haven't really timed it, but it seems that doing:
>>>
>>># q: <: 2x ^ 607
>>>
>>>is just about as fast as doing
>>>
>>>pp0 <: 2x ^ 607
>>>
>>>
>>>----- Original Message Follows -----
>>>From: Raul Miller <[email protected]>
>>>To: Programming forum <[email protected]>
>>>Subject: Re: [Jprogramming] perfect power???
>>>Date: Mon, 8 Jun 2009 12:09:15 -0400
>>>
>>>>On Mon, Jun 8, 2009 at 10:39 AM,
>>>>> <[email protected]> wrote: I would not
>>>>>think it was simpler, but if the verb returned:
>>>>> 1 - "IS" perfect power
>>>>> 0 - "IS NOT" perfect power
>>>>>
>>>>> that would be fine.
>>>>
>>>>Both Mike Day's and my own solutions work this way:
>>>>
>>> > pp0=: *./@(0&<@#, 2&<:, 1 < +./)@(#/....@q: ::0:"0)
>>>>
>>>> pp0 4
>>>>1
>>>> pp0 5
>>>>0
>>>>
>>>>FYI,
>>>>
>>>>--
>>>>Raul
>>>>---------------------------------------------------------
>>>>-- ----------- For information about J forums see
>>>>http://www.jsoftware.com/forums.htm
>>>----------------------------------------------------------
>>>------------ For information about J forums see
>>http://www.jsoftware.com/forums.htm
>>
>>-----------------------------------------------------------
>>----------- For information about J forums see
>>http://www.jsoftware.com/forums.htm
>----------------------------------------------------------------------
>For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm