Computer
posted by Nelly on .
How to write an algorithm to find the fibonacci series ???
Help:/

The fibonacci series is defined as the set of terms a(n)∈Z+ (i.e. all terms are integers) such that:
a(0)=0
a(1)=1
a(i)=a(i2)+a(i1), i≥2
The pseudocode resembles a lot the definition of the series:
Input: n
a(0)=0
a(1)=1
for i=2,i<=n,i++: a(i)=a(i2)+a(i1) next
return a(n)
Note that a closed form formula for evaluating a(n) exists, and is called the Binet's formula:
a(n)=((p^n(1/p)^n)/sqrt(5)
where p=(1+sqrt(5))/2 = the golden ratio
However, since the result has to be an integer, and the calculations required are real, there could be rounding problems with calculations performed on a digital computer, unless symbolic algebra is available.