GeeksforGeeks » Algorithms

Print large Fibonacci numbers

(1 post)
  • Started 1 year ago by sjovaxsnukbx

Tags:

  1. raj
    Member
    Posted 1 year ago #

    How to print very large Fibonacci numbers eg fib(1000).
    My approach:
    When any one of fib(i-1) or fib(i-2) has more than 12 or 13 digits, partition them into groups of 4 digits and put them in a linked list.
    fib(i-1) is put in list1, fib(i-2) in list2. Perform the addition of these long numbers and overwrite in list2.
    Now to find next fib list1 is taken as fib(i-2) and list2 as fib(i-1) and this repeats until we approach the given number and finally the result is in list2.
    As the number of digits goes on increasing, the list is constructed dynamically.

    If anyone has an efficient approach pls tell me.


Reply

You must log in to post.

RSS feed for this topic