[This page is auto-generated; please prefer to read the article’s PDF Form.]
The Fibonacci Sequence is defined as:
n | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
F n | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 | 89 | 144 | 233 | 377 |
Given an integer n > 2, we need to write a program to calculate Fn.
Fibonacci numbers grow very fast with n and cannot be represented in 64-bits for n larger than 93:
So such a program needs to use additional software mechanism to represent these large numbers and perform operations on them. In this article, we do not discuss about handling large numbers and only write programs with integer type “long” in C. These programs can be adapted to use data-types and operations for large numbers, while keeping the algorithm same.
[Next]
Copyright © 2020 Nitin Verma. All rights reserved.