Primality by trial division: Difference between revisions
Content deleted Content added
→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details |
|||
Line 1,626: | Line 1,626: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
<lang scala>// version 1.1. |
<lang scala>// version 1.1.2 |
||
fun isPrime(n: Int): Boolean { |
fun isPrime(n: Int): Boolean { |
||
if (n < 2) return false |
if (n < 2) return false |
||
if (n % 2 == 0) return n == 2 |
if (n % 2 == 0) return n == 2 |
||
val limit = Math.sqrt(n.toDouble()).toInt() |
val limit = Math.sqrt(n.toDouble()).toInt() |