问问这个问题,初学kotlin不太懂使用,Math.pow()显示使用错误:Type mismatch: inferred type is IntegerLiteralType[Int,Long,Byte,Short] but Double was expected
fun main() {
println("please enter a num from 1 to 100: ")
val iInput : String? = readLine()
val i : Int = iInput!!.toInt()
var sum = 0.0
for(j in 1..i+1){
sum += Math.pow(-1,j+1)/(2*j-1)
}
var s : Double = 4*sum
println("当i=$i" + "时,s=$s")
}