-1
How to print the first 12 terms of the Fibonacci sequence in reverse in Pascal? Instead of 1 to 12, 12 to 1
program Exercicio_31;
var V:array[3..12]of integer;I,termo1,termo2,novoTermo:integer;
begin
writeln('Serie de Fibonacci');
writeln('==================');
termo1 := 1;
termo2 := 1;
writeln(' 1o. termo = ', termo1);
writeln(' 2o. termo = ', termo2);
for I:=12 downto 3 do
begin
novoTermo := termo1 + termo2; { o novo termo e a soma dos dois termos anteriores }
writeln(I:2, 'o. termo = ', novoTermo);
termo1 := termo2; {o segundo termo e o primeiro termo no proximo passo }
termo2:=novoTermo; { o novo termo e o segundo termo no proximo passo }
end;
writeln('==================');
writeln;
write('Pressione [algo] para prosseguir.');
readkey;
end.
Apparently it’s a college issue.
– Murillo Goulart
Yeah, it’s from college.
– Marco Aurélio Lopes Júnior
Before asking the question directly, sponge how it tried to arrive at the solution and the problems it found in the implementation. Do not present the question directly without showing any effort.
– André Luiz