Wednesday 26 April 2017

9.Fibonacci Roots

                                Fibonacci Roots

The first two terms in the Fibonacci sequence are 0 and 1, respectively, and each subsequent term is the sum of the previous two. Using this definition to calculate the first several terms in the sequence, we get
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Let us define the Fibonacci roots of a positive integer n to be the two smallest consecutive Fibonacci numbers whose sum is greater than or equal to n.

Input Format:
Input consists of a single integer which corresponds to n.
Assumption:
Assume that n is less than or equal to 2000.
Output Format:
Output consists of integers, separated by a space.

Sample Input 1 :
31
Sample Output 1:
13 21

Sample Input 2 :
89
Sample Output 2:

34 55

code:


No comments:

Post a Comment