25.03.2015 Views

Solução dos exercícios - UFMG

Solução dos exercícios - UFMG

Solução dos exercícios - UFMG

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

function l6p30;<br />

I = input('Digite um numero: ');<br />

RET = FAT(I);<br />

if ( RET == -1 )<br />

fprintf(1,'Impossivel calcular o fatorial de %d\n',I);<br />

else<br />

fprintf(1,'O Fatorial de %d eh %d\n',I,RET);<br />

end<br />

function F = FAT(N);<br />

if ( N < 0 )<br />

F = -1;<br />

elseif (N == 0)<br />

F = 1;<br />

else<br />

F = N * FAT(N-1);<br />

end<br />

<strong>UFMG</strong> – ICEx – DCC – Programação de Computadores – 1º. Sem 2005 – David Menoti 13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!