Pergunta de entrevista da empresa Meta

In sudo-code write a program that takes an integer called N and prints out the Fibonacci sequence to the Nth digit.

Respostas da entrevista

Sigiloso

6 de mai. de 2009

First I'd clarify the exact definition of the sequence (whether you consider the first number to be 0 or 1). You may need to adjust N by 1 before calling the program. int Fib(int N) { int prevprev = 0; int prev = 1; for (int i = 0; i < N; i++) {print prevprev; int cur = prevprev + prev; prevprev = prev; prev = cur; }}

2

Sigiloso

13 de jul. de 2011

@Anon: The question was about printing it till 'Nth digit', not n times.