Why am i not able to print 47th fibonacci number correctly?

前端 未结 4 1576
梦如初夏
梦如初夏 2021-01-29 16:40

I am using 64 bit operating system ,then also i am not able to print 46th fibonacci number correctly which is less than 4 billion.

#include
#inclu         


        
4条回答
  •  时光说笑
    2021-01-29 17:03

    i am not able to print 46th fibonacci number correctly which is less than 4 billion.

    You are most probably going out of range of an integer, which is from -4294967296 to 4294967295.

    Change int array[n]; to long long array[n];

    Also, the printf's should be changed from %i to %lli

    Edit : On running the numbers, you get expected value of F(48) as 4807526976 which is out of range of an integer.

提交回复
热议问题