Pregunta de entrevista de Meta

Write a method to generate the Fibonacci series

Respuestas de entrevistas

Anónimo

16 abr 2010

void print_fib(int length) { int prev_prev = 0, prev = 1, current = 1; while (length--) { printf(" %d", prev_prev); prev_prev = prev; prev = current; current = prev_prev + prev; } printf("\n"); }

2

Anónimo

20 nov 2011

tail recursion is far from enough to make recursion fast enough, you'll need to use memoization, and even if you do that, the code will still be slower and especially much more memory consuming than the one in the post of April 15, 2010 Recursion without memoization will take exponential time.

Anónimo

14 oct 2010

The recursive Sep 24 answer is too inefficient; you can still use recursion if you want, but think of a tail recursive method...

Anónimo

3 abr 2010

Write a method to generate the Fibonacci series

Anónimo

24 sep 2010

int fib(int n) { if (n < 2) return n; return fib(n - 1) + fib(n - 2); }