Ask your own question, for FREE!
Mathematics 16 Online
OpenStudy (anonymous):

need an algorithm for the Fibonacci sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,

OpenStudy (anonymous):

which language?

OpenStudy (anonymous):

portuguese or english

OpenStudy (anonymous):

LOL.. Didnt meant that. Which computer language? Sou portugues já agora

OpenStudy (anonymous):

In c++ for example, it would be something like: int i, l; int j, k=1; for (i=0; i<100; i++) { l = j + k; cout << l; j = k; k = l; }}

OpenStudy (anonymous):

pascal

OpenStudy (anonymous):

Pascal: program fibo; var result : longint; num,i, error: integer; strnum: string; function fib(n : integer) : longint; begin if n <= 2 then fib := 1 else fib := fib(n-2) + fib(n-1); end; begin if ParamCount = 0 then begin writeln('Enter integer:'); readln(strnum); val(strnum,num,error); end else begin val (ParamStr(1), num, error); end; for i := 1 to num do begin result:= fib(i); writeln(i, ' : ', result); end; end.

OpenStudy (anonymous):

thanks Dalvoron and Diogo

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!