Apr 24, 2020

write a program with a recursive function using fibonacci series?

Elden Dedon: int i = 0; int f; int Fibonacci( int n ){ if( n > a million ) { f += Fibonacci( n - a million ); return f; } else return a million; } This function will loop till it receives to n = a million, then artwork its some time past down the stack, including the Fibonacci numbers because it is going. The n - a million is substantial here because of fact the function desires a factor to offer up calling itself so it may start up working its way outward and returning values.

Raleigh Lufkin: well, what is fibonacci?1, 1, 2, 3, 5, 8, 13, 21.....fib(n) = fib(n-1) + fib(n-2) and fib(1) = 1, fib(1) = 1three cases here when n=0 n=1 and when n>1 that means if, else if, elsein the general case your function should call itself with n-1 and n-2

Hyman Coren: Well, this would be a good start:int fibb(int n){

Jonathan Schlussel: IF you specify the Programming Language =THEN we can start to help.

No comments:

Post a Comment