lunes, 18 de noviembre de 2013

exercise in pseudocode

1. Make an algorithm to generate the following series given the number of terms to generate (n).

1, -2 / 3, 3/9, 4/27, 5/81 .............

R / /

Integer n;

Integer D = 1;

Whole DV = 1;

Whole Cont = 1;

While (Cont <= n)

{

       if (D mod 2 = 0)

      {

         print (D * (-1) / DV)

     }

  but

{

  print (D / DV)



}

  Cont = Cont + 1;

  D = cont;

DV = DV * 3

}

0 comentarios:

Publicar un comentario

deja un comentario