Thanks again,  Raul.

Well - I'd actually meant ~2^24 odd numbers,  1... _1+2^25 - trust me
to make a mistake in trying to simplify the presentation!   Let's call it
a typo.

I don't think my post was a spoiler,  as the problem needs quite a bit
of insight elsewhere;  this array helps in getting the answer.

You're right, of course, for that expression, ~50 seconds on this laptop,
which produces one extended scalar result,  but unfortunately I need the
whole vector of cumulative products, 1 3 15 105...

These time and space tests are for lower size arrays:
    1 ts'281474976710656&|@*/\x:1+2*i.2^10'

1.90882 628864

   1 ts'datatype 281474976710656&|@*/\x:1+2*i.2^11'

7.91167 1.25146e6

   1 ts'q =: 281474976710656&|@*/\x:1+2*i.2^12'

30.8606 2.49638e6

    7!:5<'q'   NB. space required for ~2^12 extended elements.

589824

    2 10 >.@^.589824  NB. rounded up log 2 & log 10 space.

20 6


So 2^24 elements are likely to need around 2^40, 10^12 bytes.
This laptop only has about 16GB.


So,  I think the cludgy "cumoddprod" or its like remains the
answer for a few more Moore cycles!

Thanks,


Mike

On 16/05/2017 13:44, Raul Miller wrote:
Forgive me for asking, but isn't 33554431 = _1+2^25 ?

Anyway, this seems to work for me:

    281474976710656&|@*/x:1+2*i.2^23

I'll leave out the answer, out of respect for project euler (though
maybe the rules allow that now?).

    timespacex'281474976710656&|@*/x:1+2*i.2^23'
12.457 1.67937e9

... and needs about 13 seconds and about 2 gig ram.

That said, I suppose it would be nice if x m&|@* y worked reliably for
fixed precision integers x, m and y

Thanks,




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to