Advertisement
faysalneowaz

Febonacci

Dec 9th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int  nextTerm = 0, n,n2;
  5.  
  6.     printf("Enter a positive number: ");
  7.     scanf("%d %d", &n,&n2);
  8.     int t1 = n, t2 =n + 1;
  9.     printf("Fibonacci Series: %d %d ", t1, t2);
  10.  
  11.     nextTerm = t1 + t2;
  12.  
  13.     while(nextTerm <= n2)
  14.     {
  15.         printf("%d ",nextTerm);
  16.         t1 = t2;
  17.         t2 = nextTerm;
  18.         nextTerm = t1 + t2;
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement