13.07.2015 Views

Corretude - UFCG

Corretude - UFCG

Corretude - UFCG

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introdução Indução Algoritmos Recursivos Algoritmos IterativosExemplo 8Prove que o algoritmo do fatorial recursivo é correto.◮ Conjectura: Fat(n) = n!, para n ≥ 0◮ Caso Base: Se n = 0, então Fat(n) = 1. Isso é correto jáque 0! = 1.◮ Hipótese indutiva: Agora assumimos que Fat(k) = k!◮ Mostrar: Fat(k + 1) = (k + 1)!◮ Passo Indutivo: ComoFat(k + 1) = (k + 1) · Fat(k)e pela hipótese indutiva Fat(k) = k!, segue queFat(k + 1) = (k + 1) · k! = (k + 1)!Prof. Dr. Leandro Balby Marinho 21 / 44 <strong>UFCG</strong> CEEI

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

Saved successfully!

Ooh no, something went wrong!