Is short-circuit evaluation possible with parfor() ?

[email protected] Tue, 10 Feb 2026 00:45:28 +0100
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
Two months ago I got my first sequence approved on oeis.org:
"Numbers k such that no numbers of the form 1 + (product of k distinct 
primes of first k+1 primes) are prime."
https://oeis.org/A391020

The Pari code I provided uses forsubset (although not needed) which 
cannot be parallelized, and vecprod of primes instead of Pari primorial 
operator.

Now I have a parallel isok2() version which works superfast:

hermann@x3950-X6:~$ gp -q
? default(nbthreads)
192
? isok2(n) = 
{s=0;p=prime(n+1)#;export(s,p);parfor(i=2,n+1,ispseudoprime(1+p/prime(i)),r,s+=r);s==0};
? isok2(1993)
1
? ##
   ***   last result: cpu time 1h, 24min, 36,945 ms, real time 28,186 ms.
? isok2(1994)
0
? ##
   ***   last result: cpu time 1h, 25min, 5,259 ms, real time 28,404 ms.
?

So for numbers of A391020 the complete loop has to be executed in order 
to conform no prime exists. But for 1994 which does not belong to 
A391020 computation should be aborted on first prime detection. Is 
short-circuit evaluation like available for boolean expressions in eg. 
C++ possible for parfor() somehow?

Regards,

Hermann.