Skip to content

Instantly share code, notes, and snippets.

@magniff
Created September 9, 2022 20:39
Show Gist options
  • Select an option

  • Save magniff/6a4cc05223a253407e3c3996f3d911e4 to your computer and use it in GitHub Desktop.

Select an option

Save magniff/6a4cc05223a253407e3c3996f3d911e4 to your computer and use it in GitHub Desktop.
walrus
(
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