Created
March 11, 2010 16:54
-
-
Save voyeg3r/329342 to your computer and use it in GitHub Desktop.
python - calculando o fatorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # # -*- coding: UTF-8 -*- | |
| # Criado em:Qui 11/Mar/2010 hs 13:34 | |
| # Last Change: Qui 11/Mar/2010 hs 13:34 | |
| # vim:ft=python:nolist:nu: | |
| # Instituicao: <+nome+> | |
| # Proposito do script: <+descreva+> | |
| # Autor: <+seuNome+> | |
| # site: <+seuSite+> | |
| import os | |
| # limpando a tela | |
| if os.name == 'posix': | |
| os.system('clear') | |
| else: | |
| os.system('cls') | |
| def fatorial(n): | |
| """Função recursiva que retorna o valor do fatorial de um numero dado. | |
| """ | |
| if n <= 1: | |
| return 1 | |
| else: | |
| return (n * fatorial(n-1)) | |
| if __name__ == '__main__': | |
| n = int(raw_input("digite o fatorial a ser calculado: ")) | |
| print fatorial(n) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment