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; }
ReplyDeleteThank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am
on the look for such information.
Function Point Estimation Training in Chennai
The CBSE will allow the applicants to download their Admit Card NEET from the Boards official website along with the format for affixing of postcard size photograph.
ReplyDelete