Iterative Fibonacci algorithm giving me a wrong result after fib(47)

前端 未结 3 1930
旧巷少年郎
旧巷少年郎 2020-12-11 13:43

I am using the iterative fib algorithm that I have copied below. I have found this algorithm on Rosetta code and it gives me the correct answer up until fib(46). After that

3条回答
  •  生来不讨喜
    2020-12-11 14:18

    You have to use long long also for fnow, fnext, and tempf, try:

    long long int fnow = 0, fnext = 1, tempf;
    

提交回复
热议问题