Created
May 7, 2015 01:14
-
-
Save Irvingutierrez/90b9805598d2668d68dd to your computer and use it in GitHub Desktop.
WSQ09
This file contains 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
print() | |
print() | |
print("This program is used to calculate de factorial number ") | |
print("of a positive integer") | |
print() | |
validacion=0 | |
while validacion==0: | |
print("Introduce an integer number: ") | |
num=int(input()) | |
def factorial_0 (a): | |
a=1 | |
return a | |
def factorial_num (a,b): | |
while b>1: | |
b=b-1 | |
a=a*b | |
return a | |
return b | |
if num==0: | |
factorial_cero= factorial_0(num) | |
print("The factorial number of 0 is: ", num) | |
else: | |
contador=num | |
factorial= factorial_num(num,contador) | |
print("The factorial number of ", num, " is: ", factorial) | |
validacion=3 | |
while validacion==3: | |
print() | |
print("Do you want to try it again?(y/n)") | |
r=str(input()) | |
print() | |
if r=="Y" or r== "y": | |
validacion = 0 | |
elif r=="n" or r== "n": | |
print("Goodbye ;)") | |
validacion = 1 | |
else: | |
print("Please enter a valid character") | |
validacion = 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment