Created
September 9, 2022 20:39
-
-
Save magniff/6a4cc05223a253407e3c3996f3d911e4 to your computer and use it in GitHub Desktop.
walrus
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
| ( | |
| sys := __import__("sys"), | |
| your_value := input(), | |
| factorial := lambda value: 1 if not value else factorial(value-1) * value, | |
| ( | |
| print("Error: Your input is not a decimal number"), | |
| sys.exit(1), | |
| ) | |
| if not str.isdecimal(your_value) | |
| else (result := factorial(int(your_value))), | |
| print("Factorial of %s is %s" % (your_value, result)) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment