Richard Donovan wrote: > > Is anyone working on this problem? > Yes: I solved it in J.
> I tried: > > +/ 1 p: <: +: *: >: i. 10000 > 2202 > > To confirm the algorithm was working for n <: 10,000 > > But the actual problem is for n <: 50,000,000 and my algorithm > only works as far as 30,000 before taking excessive time. If you are going to test every number for primality, you should use the Miller-Rabin test from http://www.jsoftware.com/jwiki/Essays/Primality_Tests However, this will still take a long time in any language. The problem can actually be solved using no explicit primality testing at all. I can write a Java program using this algorithm that runs in a few seconds, but adapting it to J is still too long. I ended up using a mixed strategy, with some shortcuts based on the behavior of the sequence being tested, and some primality testing. I was not completely happy with the result, but it was within reason. Best wishes, John ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
