kucheasysa

fibb

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