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

前端 未结 4 1613
梦如初夏
梦如初夏 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 16:58

    Either Use an unsigned integer array or for more higher values use unsigned long long long array but you don't need an array to print fibonacci series you can simply do this:-

    void main()
    {
      unsigned long long i=1, num1=1, num2=0;
      printf("1 \n");
      for(i; i<100 ; i++)
       {
         num1=num1+num2;
         num2=num1-num2;
         printf("%lli \n", num1);
       }
      getch();
     }
    

提交回复
热议问题