Skip to content

Instantly share code, notes, and snippets.

@aaclarker
Created February 15, 2024 00:42
Show Gist options
  • Save aaclarker/a24f1cb98e438b08b7489489ba92e6e5 to your computer and use it in GitHub Desktop.
Save aaclarker/a24f1cb98e438b08b7489489ba92e6e5 to your computer and use it in GitHub Desktop.
choice = "y"
while choice.lower() == "y":
number = int(input("Enter a number to calculate factorial: "))
result = 1
for i in range(1, number + 1):
# Factorial = 1 x 2 x 3 x ... x n
result *= i
print(number, "factorial is", result)
choice = input("Calculate another? y/n: ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment