At Wednesday 29/11/2006 20:35, Steve Bergman wrote:
BTW, strictly speaking, shouldn't I be adding something to the floating
point sqrt result, before converting to int, to allow for rounding
error? If it is supposed to be 367 but comes in at 366.99999999, don't
I potentially classify a composite as a prime?
You could avoid sqrt using divmod (which gets the % result too); stop
when quotient<=divisor.
But this approach creates a tuple and then unpacks it, so you should
time it to see if there is an actual speed improvement.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
--
http://mail.python.org/mailman/listinfo/python-list