https://kotlinlang.org logo
#announcements
Title
# announcements
d

Dalinar

05/20/2017, 12:32 PM
what is wrong with this code? why does it return a negative value (if I use a lower number like
20
it seems to work, but a number like
100
will also cause a large negative value )
println(fibonacci(50).last())
fun fibonacci() = generateSequence(Pair(0, 1), { Pair(it.second, it.first + it.second) }).map { it.first }
fun fibonacci(n: Int): Sequence<Int> = fibonacci().take(n)
m

mg6maciej

05/20/2017, 12:36 PM
mishaxz: Not Krelated, goto:stackoverflow Use
BigInteger
.
3 Views