loup-vaillant comments on The dangers of zero and one - Less Wrong

27 Post author: PhilGoetz 21 November 2013 12:21PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (68)

You are viewing a single comment's thread. Show more comments above.

Comment author: loup-vaillant 28 November 2013 01:18:02PM *  1 point [-]

(7): indentation error. But I guess the interpreter will tell you i is used out of scope. That, or you would have gotten another catastrophic result on numbers below 10.

def is_prime(n):
for i in range(2,n):
    if n%i == 0: return False
return True

(Edit: okay, that was LessWrong screwing up leading spaces. We can cheat that with unbreakable spaces.)

Comment author: gjm 28 November 2013 03:05:48PM 1 point [-]

indentation error

Yes, good point. I'd generalize: "I could have committed some syntax error -- wrong indentation, wrong sort of brackets somewhere, etc. -- that just happens to leave a program with correct syntax but unintended semantics."

I guess the interpreter will tell you i is used out of scope.

Depends on exactly what error occurs. (With the formatting the way it actually looks here it would just be a syntax error.)

That, or you would have gotten another catastrophic result on numbers below 10.

This (aside from the simplicity of the code) is the real reason why I'm still happy with an error probability less than 0.001. It takes a really odd sort of error to produce correct results for the first 100 candidate primes and wrong results thereafter. I could write some programs with that sort of error, but they wouldn't look at all like naive primality checkers with simple typos.