Fibonacci series program in C language: int fib(int n) { int a = 1, b = 1; for (int i = 3; i <= n; i++) { int c = a + b; a = b; b = c; } return a; }

This is an iterative way to just compute and return the nth number in the fibonacci series (without storing the previous numbers)

this is an iterative way to generate fibonacci series of n-numbers.

This is an recursive way to just compute and return the nth number in the fibonacci series (without storing the previous numbers)

this is recursive way to generate fibonacci series of n-numbers.

It was helpful. Thanks.

Back To Top