| hermann on Thu, 25 Apr 2024 07:49:22 +0200 | 
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Better than "r=rec(...);if(r,return(r))" to end frst solution recursion? | 
Restating my question differently: Is there a break(2) "equivalent" of return(), allowing to leave current function and its directly calling function? ? ?breakbreak({n=1}): interrupt execution of current instruction sequence, and exit
from the n innermost enclosing loops.
? ?return
return({x=0}): return from current subroutine with result x.
?
Regards,
Hermann.
On 2024-04-11 10:42, hermann@stamm-wilbrandt.de wrote:
Last night I improved a "by hand" backtracking function to one "with 
recursion":
(factors 300 decimal digit semiprime n in ms, with both primes
consisting of digits 3 and 7 only)
https://www.mersenneforum.org/showthread.php?p=654845#post654845
rec(n,p=0,q=0,m=1)={
if(n==p*q,return(p));
forstep(P=3*m,7*m,4*m,
forstep(Q=3*m,7*m,4*m,
if((n-(p+P)*(q+Q))%m==0,
r=rec(n,p+P,q+Q,10*m);if(r,return(r)))));}
I seem to remember that I got solution for "testret()" here before in
some posting, but cannot find.
testret(r)=... ?
allowing for
if((n-(p+P)*(q+Q))%m==0,
testret(rec(n,p+P,q+Q,10*m)))));}
Regards,
Hermann.