mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 15:53:46 +00:00
11 lines
284 B
Kotlin
11 lines
284 B
Kotlin
tailRecursive fun test(x : Int, a : Any) : Int =
|
|
if (x == 1) {
|
|
test(x - 1, "no tail")
|
|
1 + test(x - 1, "no tail")
|
|
} else if (x > 0) {
|
|
test(x - 1, "tail")
|
|
} else {
|
|
0
|
|
}
|
|
|
|
fun box() : String = if (test(1000000, "test") == 1) "OK" else "FAIL" |