Jump to content

Recursividade


Carlos Henrique

Recommended Posts

Usando Pascal, como montar um programa recursivo que mostre em vídeo a seguinte sequencia?

5   10  15  20  25
6   12  18  24
7   14  21
8   16
9

Não estou conseguindo montar a fórmula para achar os valores das linhas e colunas.

Nesse caso vamos supor N = 5.

Edited by pwseo
tags code, cleanup
Link to comment
Share on other sites

Sou iniciante:

usando procedimentos a seguir:

Procedure imprime_coluna( i{e}, N{e}: integer );
begin
   if i <= N then
   begin
       write((i)*(n):4);
       imprime_coluna(i + 1, n);
   end;
end;

Procedure Imprime_linha( i{e},N{e}: integer );
begin
   if i - 1 <= N then
   begin
       imprime_coluna(i, N);
       writeln;
       writeln;
       imprime_linha( i+1, N );
   end;

que fornece um resultado parecido, mas não verdadeiro. Não consigo chegar a uma fórmula que resolva tal problema.

Edited by pwseo
syntax highlight, cleanup
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.