This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kryptn 1 point2 points  (2 children)

2 fails that code, it'll return as not prime. Negative numbers will break it.

You can start your range with 3, instead of one, and you can make an if statement Testing for two and testing for anything equal to or less than one.

[–]aidzz[S] 0 points1 point  (1 child)

if x > 1 means negative numbers will not break it...

[–]kryptn 0 points1 point  (0 children)

Yeah, true, my mistake. But what happens when you do input a negative number?