|
Program describes an easy way to find the Fibonacci numbers
below a given number.
Logic: Fibonacci numbers are the the numbers fall
on the Fibonacci series, which grows up accord to Fibonacci
rule. The rule is that, the present number in the series is
the sum of past number and the number before last. The series
starts from 0, and the 2nd term is 1.
Mathematically,
F(n+1) = F(n) + F(n-1)
// F(1) =0 and F(2) = 1
Programmatically, that is what exactly we are doing. The
while loop traces till the upper limit. In each iteration we
keep a flag to store last to iteration results to proceed to
the next.
|