Interview Solution

There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. C.A.R. Hoare

Fibonacci Number

Language Java | Level Intermediate | Category Interview Problems | July 24, 2015 4:52 pm

Comments


Interview Problem

Fibonacci number is a number that start with one or zero and next number is equal to the sum of previous two numbers. Ex F (0) = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34..
The first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.,
Example:-
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, .


Output

   					 
Print the first 10 Fibonacci numbers using iterative funcation:1 1 2 3 5 8 13 21 34 55  
Print the first 10 Fibonacci numbers using recursive funcation:1 1 2 3 5 8 13 21 34 55

				    

Comments



Please login to add comments.