Learn basic concept of c , c++ and python programming in regularcodes.com

Spread the post

Fibonacci series of given n number

Write an efficient algorithm to print Fibonacci series with given N number. in this post given a recursive solution of this problem.

Accepted Output

Fibonacci of [15] number : 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

Fibonacci of [20] number : 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

Visualize process.

Stack Areamainfibonacci_noelement (int) =15no1 (int) =0no2 (int) =1fibonacci_noelement (int) =14no1 (int) =1no2 (int) =1fibonacci_noelement (int) =13no1 (int) =1no2 (int) =2fibonacci_noelement (int) =12no1 (int) =2no2 (int) =3fibonacci_noelement (int) =11no1 (int) =3no2 (int) =5fibonacci_noelement (int) =10no1 (int) =5no2 (int) =8fibonacci_noelement (int) =9no1 (int) =8no2 (int) =13fibonacci_noelement (int) =8no1 (int) =13no2 (int) =21fibonacci_noelement (int) =7no1 (int) =21no2 (int) =34fibonacci_noelement (int) =6no1 (int) =34no2 (int) =55fibonacci_noelement (int) =5no1 (int) =55no2 (int) =89fibonacci_noelement (int) =4no1 (int) =89no2 (int) =144fibonacci_noelement (int) =3no1 (int) =144no2 (int) =233fibonacci_noelement (int) =2no1 (int) =233no2 (int) =377fibonacci_noelement (int) =1no1 (int) =233no2 (int) =377

Spread the post

Recommended Posts: