Project Euler #484
https://projecteuler.net/problem=484
is particularly troublesome. My solution is:
f =: monad define
T =: 5 * 10^15
ctr=:1
sum =: 0
func=:+.(+/@:(1&(*/\.))@:q:)
while. ctr < T + 1 do.
sum =: sum + func ctr
ctr =: ctr+1
end.
sum
)
But on my Mac this causes a crash. (Doing a tacit one-liner with +/ gives an
out of memory error). So I am at a loss how to do this in J. 10^15 seems
absurdly large, so perhaps I'm missing a trick.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm