19 lines
405 B
Kotlin
19 lines
405 B
Kotlin
import kotlin.math.sqrt
|
|
|
|
// Kotlin prime number finder
|
|
|
|
fun main(args: Array<String>) {
|
|
val max = args[0].toInt()
|
|
for (n in 3..max step 2) {
|
|
var isPrime = true
|
|
for (i in 3..sqrt(n.toDouble()).toInt() step 2) {
|
|
if (n % i == 0) {
|
|
isPrime = false
|
|
break
|
|
}
|
|
}
|
|
if (isPrime) {
|
|
println(n)
|
|
}
|
|
}
|
|
} |