1st year of college, second semester in, and i think i'm on the verge of failing, so i thought i'd finally join to get some good advice. my teacher is ok, but mostly unclear on how to do certain things. This time, its recursive functions.
i am suppose to write a recursive function to find the nth Fibonacci number and then find the run-time. this is what i think i'm suppose to do:
but where do i put the "cin" to enter in the nth term? then at the end i believe im suppose to put:Code:long int fib(int n) { if (n==1 || n==2) return 0; else return fib (n-1) + fib(n-2); }
although im not positive on the clock thing. 50 minute lesson on this and i came out not having a clue. hopefully someone can clear thing up for me. Thanks in advance!!Code:int main () { int start, end, n; start=clock(); cout << #(n); end=clock(); cout << "Run-time- " << (end-start)/1000 return 0; }




Reply With Quote