How to calculate the average of a list of double values in Kotlin

1 Answer

0 votes
fun main() {
    val list = listOf(3.14, 8.0, 2.87, 5.982, 10.0)
 
    println("average = %f". format(list.average()))
}





/*
run:

average = 5.998400

*/

 



answered Oct 17, 2022 by avibootz
...