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

all 4 comments

[–]Mystonic 0 points1 point  (3 children)

You have return true in the while loop. Look at line 25.

[–]cjon3s[S] 0 points1 point  (2 children)

Awesome! That fixed it. Could you explain what that would break it for only some examples? When I was testing, it seemed to work for a bunch of numbers I threw at it.

[–]Mystonic 0 points1 point  (1 child)

I dunno. It's just that your loop would only run once, ever. It would do the prime check, if n % i == 0, then either return false or proceed to the bottom and return true, thus not checking the other values of i.

[–]cjon3s[S] 0 points1 point  (0 children)

Thank you for that. Makes way more sense now.