+ 2

Fibonacci sequence help!!

When I try find the 94. fibonacci terms, result is not logiccally, like -123458796487. What should I do in C/C++ when I want find sum of big numbers?

12th May 2018, 4:12 PM
Ali B.
Ali B. - avatar
15 Answers
12th May 2018, 6:14 PM
AliR૯za
AliR૯za - avatar
+ 15
https://code.sololearn.com/cSC16oNf6laZ/?ref=app
12th May 2018, 6:26 PM
Shimon
Shimon - avatar
+ 6
Ali B., you need an even more complex algorithm and a very powerful hardware system such as a supercomputer or something like that!
12th May 2018, 4:53 PM
Naveen Maurya
Naveen Maurya - avatar
+ 5
Sreejith, but this is valid only upto 93 terms! AliR૯za's code works upto 140 terms! (as per SoloLearn's time limit)
12th May 2018, 4:44 PM
Naveen Maurya
Naveen Maurya - avatar
+ 4
Then try something like this: AliR૯za's code: https://code.sololearn.com/caP8649IZ2fH/?ref=app
12th May 2018, 4:30 PM
Naveen Maurya
Naveen Maurya - avatar
+ 2
use long int
12th May 2018, 4:16 PM
‎ ‏‏‎Anonymous Guy
+ 1
actually firstly I did long long but gave same error then I tried long int again same :)
12th May 2018, 4:24 PM
Ali B.
Ali B. - avatar
+ 1
long long int not just long long
12th May 2018, 4:25 PM
‎ ‏‏‎Anonymous Guy
+ 1
Ali B. your code is working perfectly no errors
12th May 2018, 4:35 PM
‎ ‏‏‎Anonymous Guy
+ 1
but I need sum of terms till the 4billion
12th May 2018, 4:49 PM
Ali B.
Ali B. - avatar
12th May 2018, 4:20 PM
Ali B.
Ali B. - avatar
0
try long long
12th May 2018, 4:23 PM
‎ ‏‏‎Anonymous Guy
0
yes I wrote like this you can check the code https://code.sololearn.com/cV91JXi8XNyy/?ref=app
12th May 2018, 4:29 PM
Ali B.
Ali B. - avatar
0
Sreejith no there is error 94th term
12th May 2018, 4:43 PM
Ali B.
Ali B. - avatar
0
num = int(input()) def f(n): #complete the recursive function u=0 v=1 print(0) print(1) for i in range(2,n): c=u+v u=v v=c print(v) f(num)
11th Nov 2020, 12:18 PM
Rupan Dutta
Rupan Dutta - avatar