[Tutor] Use flag to exit?

Richard D. Moores rdmoores at gmail.com
Thu Jun 24 07:31:47 CEST 2010


I've read (I can't remember where) that for every prime p there there
are positive integers a and b such that p = a + b and such that
2**a*3**b is either 1 greater than or 1 less than another (much
larger) prime. I don't know if this has been proven or not, but I've
tested it on all primes 3 < p <= 5689. Here's my script that produces
a big prime number from a small one (p > 3):
<http://tutoree7.pastebin.com/s09YniXG>.

My question is how to best exit when the big prime has been found. I
used a flag (see the highlighted lines 34,40,44), but I seem to
remember that, though they can work, flags are frowned upon by
Pythonistas, and should be used only when absolutely necessary. So, is
one necessary in my script?

Thanks,

Dick Moores


More information about the Tutor mailing list