Joined July 2014
·

Lars

my house
·
·

Posted to Prime Numbers with Python v2 over 1 year ago

Silly formatting...

Thanks for writing these up.

I may be confused, but isn't there a mistake in the baillie_psw() method?

Where it says

for i in xrange(3, limit + 1, 2):
    if n % i:
        return n == i

shouldn't the if condition say

if n % i == 0:

? Because you're going to return an answer only if n is divisible by i.

Lars

Posted to Prime Numbers with Python v2 over 1 year ago

Thanks for writing these up.
I may be confused, but isn't there a mistake in the baillie_psw() method?
Where it says
for i in xrange(3, limit + 1, 2):
if n % i:
return n == i

shouldn't the if condition say
if n % i == 0:
? Because you're going to return an answer only if n is divisible by i.

Lars

Achievements
1 Karma
0 Total ProTip Views