print fibo big numbers in c++ or c language

后端 未结 6 1296
夕颜
夕颜 2021-01-16 23:39

I write this code for show fibonacci series using recursion.But It not show correctly for n>43 (ex: for n=100 show:-980107325).

#include
#inc         


        
6条回答
  •  半阙折子戏
    2021-01-16 23:58

    Keep in mind that the n-th fibonacci number is (approximately) ((1 + sqrt(5))/2)^n.

    This allows you to get the value for n that allows the result to fit in 32 /64 unsigned integers. For signed remember that you lose one bit.

提交回复
热议问题