Created
May 9, 2019 13:49
-
-
Save aszx87410/4baf959b277ca387967ee442ca5832f7 to your computer and use it in GitHub Desktop.
判斷質數錯誤範例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPrime(n) { | |
if (n === 1) return false; | |
for (let i = 2; i < n; i++) { | |
if (n % i === 0) { | |
return false; | |
} else { | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment