Eli Zabielski wrote:
> Checking if a number is prime by deviding it by possible factors. If any 
> outcome is an integer, and it is not 1 or itself, it is prime.

A better way to check for divisibility is to use the modulo operator % 
which gives the remainder when one number is divided by another. If a % 
b == 0 then b is a factor of a.

Kent

> 
> On 12/5/06, *Kent Johnson * <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 
> wrote:
> 
>     Eli Zabielski wrote:
>      > How can I check if a variable is an integer?
> 
>     Luke and John have answered your question, but we should also ask, why
>     do you want to do that? Explicit type testing is a code smell, perhaps
>     there is a better way to do what you want.
> 
>     Kent
> 
> 
> 
> 
> -- 
> Eli Zabielski


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to