3 lines
140 B
Kotlin
3 lines
140 B
Kotlin
fun sum(lo: Int, hi: Int, f: (Int) -> Double) = (lo..hi).sumByDouble(f)
|
|
|
|
fun main(args: Array<String>) = println(sum(1, 100, { 1.0 / it }))
|