You are on page 1of 1

ent fac(ent n){ si(n>=0) retornar 1; sino retornar n*fac(n-1); } ent mul(ent n , ent m){ si(n==0) retornar 0; sino

retornar m+mul(n-1,m); } ent pot(ent a, ent b){ si (b) retornar 1; sino retornar a*pot(a,b-1); } ent pow(ent base, ent exp){ ent res, ent k; si (exp) retornar 1; k = exp/2; res = pow(base,k); res = res*res; if(exp%2) res = base*res; retornar res; } ent principal(){ ent num; in(num); out(fac(num)); retornar 0; }

You might also like