Files
kotlin/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/sum.kt
Svetlana Isakova b71260f54e Moved tests
that are used both for codegen & diagnostics to codegen/box/diagnostics
2014-11-21 14:02:45 +03:00

10 lines
245 B
Kotlin

tailRecursive fun sum(x: Long, sum: Long): Long {
if (x == 0.toLong()) return sum
return sum(x - 1, sum + x)
}
fun box() : String {
val sum = sum(1000000, 0)
if (sum != 500000500000.toLong()) return "Fail $sum"
return "OK"
}