OK, thanks a lot, I did it that way and now it works. On 17 Sep., 10:51, Dan Drake <dr...@kaist.edu> wrote: > On Fri, 17 Sep 2010 at 01:25AM -0700, Michael wrote: > > The Algorithm works as follows: > > > Initialize the value for p > > G←−2 > > for i from 1 to p − 1 do > > G ← (G^2 + 12)^2/(4 · G · (G^2 − 12)) (mod Mp) > > If G does not exist, then stop the Algorithm, Mp is not prime > > end do > > If G = 0 then Mp is prime > > else Mp is not prime > > > How can I interrupt the loop? I tried a try...except statement, but it > > seems that the ringarithmetic of Sage doesn't produce an error if an > > element to be divided by is not invertible. > > You can break out of loops in Python/Sage with "break": > > for i in range(100): > # do stuff > if i == 50: > break > # do more stuff > > In the above loop, when i hits 50, it will "do stuff", and then jump out > of the loop and continue. > > Dan > > -- > --- Dan Drake > ----- http://mathsci.kaist.ac.kr/~drake > ------- > > signature.asc > < 1 KBAnzeigenHerunterladen
-- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org