Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int count, preTerm=0, curTerm=1, newTerm;
- scanf("%d", &count);
- if (count == 0)
- {
- printf("0\n");
- }
- else if (count == 1)
- {
- printf("0 1\n");
- }
- else
- {
- newTerm = preTerm+curTerm;
- printf("%d %d", preTerm, curTerm); /* newTerming first two terms */
- while(newTerm<count)
- {
- printf(" %d",newTerm);
- preTerm=curTerm;
- curTerm=newTerm;
- newTerm = preTerm+curTerm;
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement