Jan Järfalk
03/14/2018, 7:54 PMfun getDivisors(n: Int): List<Int> {
val limit = Math.sqrt(n.toDouble()).toInt()
return (1..limit).filter { n % it == 0 }.flatMap {
val squaredIsN = it * it == n
if (squaredIsN) listOf(it) else listOf(it, n / it)
}
}