6!:2 't=: p: i.1e6'
0.176141
It looks like there's a more efficient way of doing this:
(0&(3!:1) t) (1!:2) <'/prut/x'
6!:2 'tt=: 3!:2 (1!:1) <''/prut/x'''
0.016776
tt-:t
1
Hallo Roger Hui, je schreef op 20-04-09 21:10:
> 6!:2 'p: i.1e6'
> 0.280095
> t=: p: i.1e6
> (":t) 1!:2 <'\junk\x'
> 6!:2 '". (1!:1) <''\junk\x'''
> 1.06673
>
>
>
> ----- Original Message -----
> From: "R.E. Boss" <[email protected]>
> Date: Monday, April 20, 2009 11:58
> Subject: Re: [Jprogramming] table of primes to 1,000,000,000 or more
> To: 'Programming forum' <[email protected]>
>
>
>> Well, if that is so likely, it must be easy to give an example.
>> For which reasonable large interval is it faster to generate
>> than to read
>> all primes?
>>
>>
>> R.E. Boss
>>
>>
>>
>>> -----Oorspronkelijk bericht-----
>>> Van: [email protected] [mailto:programming-
>>> [email protected]] Namens Zsbán Ambrus
>>> Verzonden: maandag 20 april 2009 19:37
>>> Aan: Programming forum
>>> Onderwerp: Re: [Jprogramming] table of primes to 1,000,000,000
>>>
>> or more
>>
>>> On Sun, Apr 19, 2009 at 6:53 PM, R.E. Boss
>>>
>> <[email protected]> wrote:
>>
>>>>> Also, a table of primes is never worth to download or
>>>>>
>> store, as it's
>>
>>>>> faster to generate them online than reading them.
>>>>>
>>>> This "never" seems incorrect, assumed reading is linear (in
>>>>
>> the number
>>
>>> of
>>>
>>>> primes) and generating is not.
>>>> How long took it to generate the largest known prime?
>>>>
>> Definitely longer
>>
>>> than
>>>
>>>> reading it.
>>>> So there is a prime after which is it worthwhile to store
>>>>
>> the larger
>>
>>> primes.
>>>
>>> The point is, it's not worth to store a table of _all primes_
>>>
>> up to a
>>
>>> certain number. Sure, just reading a single prime can be
>>>
>> fast, but if
>>
>>> you want to get all the primes in a reasonably large interval, it's
>>> likely faster to generate them then to store them.
>>>
>>> Ambrus
>>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
--
=@@i
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm