View Single Post
Old 2012-10-25, 02:10   #1
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

3×372 Posts
Default pari break() usage

pari gurus,

Can you tell me why I can't seem to get the break command to break within a loop, instead of executing the rest of the loop prior to breaking?
Code:
findcycle(a,b)=
{
    for(e=a,b,
    i=e;
    for(c=1,10,
      i=sigma(i)-i;
      if(i<e,
        break());
      if(i==e,
        print(i,"  ",c);
        break()));
      print(e))
}
I want the ifs to break out of the inner loop immediately, but they don't; they continue to the end of the loop invoking the print(e). That means if the first if is true, the second uselessly gets evaluated anyway as well as the print(e) line. If I use break(2), it breaks the outside for loop.

BTW, I have tried next(), with identical results.

I guess along an alternate route, is there an else type command?

Thanks!
EdH is offline   Reply With Quote