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, ...
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:
#include<stdio.h>
int main(){
int a=0,b=1,c=0,n;
scanf("%d",&n);
while(1){
c=a+b;
if(c>=n)
goto END;
a=b;
b=c;
}
END: printf("%d %d",a,b);
return 0;
}