YouTube Interview Question

Create a Fibonacci function and explain it.

Interview Answers

Anonymous

Nov 29, 2012

//assume n nonnegative static int fib(int n) { if( n < 2 ) return n; else { int pp = 0; //fib0 int p = 1; //fib1 for(int i=2; i

1

Anonymous

Jun 25, 2014

function fib(n){ return 1?1 : 1?2 : fib(n-1)+fib(n-2); }