+ 6
How to calculate fabonacci series that the number is over 4000000000?
6 Respuestas
+ 23
you have to use big integers.. or implement one of your own. number of digits of fib(n) for large inputs could be scary!
+ 4
An attempt, if you are interested.
https://code.sololearn.com/cqtn357OfStn/#cpp
+ 3
you could try this (im not really good at c++, but it should be possible)
a=0
b=1
c=a+b //1
and after that
var a= c //1
var b= a+b //2
var c= a+b //3
and somehow loop that, but i dont know about loops in c++
+ 2
Thank you Roel and Donna
+ 1
Use binet's formula : o(1). Or fast matrix exponent o(log(n)
https://code.sololearn.com/cEal5s0hfuC8/?ref=app