Factors of an integer: Difference between revisions

→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
m (J: also include brute force approach and some related comments)
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 2,208:
 
=={{header|Kotlin}}==
<lang scala>//fun versionprintFactors(n: 1.0.5-2Int) {
 
fun printFactors(n: Int) {
if (n < 1) return
print("$n => ")
for (i in 1 ..n n/ 2) if (n % i == 0) print("$i ")
println(n) .filter { n % it == 0 }
.forEach { print("$it ") }
println(n)
}