Created
February 2, 2018 14:03
-
-
Save theerasan/b8d67c1490dbc60de8457258469f74ed to your computer and use it in GitHub Desktop.
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
fun main(args: Array<String>) { | |
println(13.isPrimeNumber()) | |
} | |
private fun Int.isPrimeNumber(): Boolean { | |
if (this < 1) return false | |
var count = 0 | |
(1..this).forEach { | |
if (this%it == 0) count++ | |
} | |
return count == 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment