Aritmetica ricorsiva

Potenza


Iterativa
MN = Pot(M, N) = M*M*...*M (N fattori)

FUNZIONE potiter(INTERO m, INTERO m): INTERO
INIZIO
   INTERO i, risp
   risp = 1
   PER(i DA 1 A n PASSO +1)
      risp = risp*m
   potiter = risp
FINE


Ricorsiva
oppure
FUNZIONE potric(INTERO m, INTERO m): INTERO
INIZIO
   SE(N == 0) ALLORA
      potric = 1
   ALTRIMENTI
      potric = M*potric(M, N-1)
FINE
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki