Info

So, here is a sneaky replacement to line 7 of PrimeFinder.py. If TestFactor does not divide PrimeTest evenly, then the quotient is rounded off, and so the comparison will fail:

if ((PrimeTest/TestFactor)*TestFactor == PrimeTest)

Python uses the float class for floating-point (decimal) numbers. The float function transforms a value into a float:

>>> float(8)/float(3) # Give me the "real" quotient.

Was this article helpful?

0 0

Post a comment