Advertisement
aiNayan

7(vii)

Dec 7th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. int fibo(int);
  3. int main()
  4. {
  5. int n, i = 0, j;
  6. printf("Enter the length: ");
  7. scanf("%d", &n);
  8. printf("Fibonacci series:\n");
  9. for (j = 1; j <= n; j++) {
  10. printf("%d ", fibo(i));
  11. i++;
  12. }
  13. return 0;
  14. }
  15. int fibo(int n)
  16. {
  17. if (n == 0 || n == 1)
  18. return n;
  19. else
  20. return (fibo(n - 1) + fibo(n - 2));
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement