Advertisement
Guest User

fibonacci

a guest
Feb 29th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3. int i, n, t1 = 0, t2 = 1, next;
  4. printf("Enter the number of terms: ");
  5. scanf("%d", &n);
  6. printf("Fibonacci Series: ");
  7.  
  8. for (i = 1; i <= n; ++i) {
  9. printf("%d, ", t1);
  10. next = t1 + t2;
  11. t1 = t2;
  12. t2 = next;
  13. }
  14.  
  15. return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement