Last active
September 1, 2015 23:53
-
-
Save MauricioDinki/d92dfcbb957278fd800c to your computer and use it in GitHub Desktop.
Get the factorial of a number using python validations
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
factorial = 1 | |
number = raw_input("Insert a number\n") | |
if number is '': | |
print("No ingresaste Nada") | |
elif number.isspace(): | |
print("Insert some blank") | |
elif number.isalpha(): | |
print("Words don't have factorial") | |
elif int(number) < 0: | |
print("Negative numbers don't have factorial") | |
elif int(number) is 0: | |
print("Factorial of 0 is 1") | |
else: | |
numberlimit = int(number) + 1 | |
long(factorial) | |
for i in range(1, numberlimit): | |
factorial = factorial * i | |
print("The factorial of %s is %s")%(number,factorial) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment