Created
January 31, 2016 11:36
-
-
Save hkasera/6221301829becc0f240f to your computer and use it in GitHub Desktop.
JavaScript Questions
This file contains hidden or 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
| var checkPrime = function(n) { | |
| "use strict"; | |
| if (n === 1) { | |
| return false; | |
| } | |
| var isPrime = true; | |
| for (let i = 2; i < n;) { | |
| if (n % i === 0) { | |
| isPrime = false; | |
| } | |
| if (n > 3) { | |
| i = i + 2; | |
| } else { | |
| i++; | |
| } | |
| } | |
| return isPrime; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment