Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Number With Exclamation by Julia_Swiatek
def factorial(n: int) -> int:
# your code here
return 0
def factorial(n):
if n == 0 or n == 1:
return 1
else:
result = 1
for i in range(2, n + 1):
result *= i
return result
print("Example:")
print(factorial(4))
# These "asserts" are used for self-checking
assert factorial(0) == 1
assert factorial(1) == 1
assert factorial(5) == 120
assert factorial(10) == 3628800
assert factorial(15) == 1307674368000
print("The mission is done! Click 'Check Solution' to earn rewards!")
Jan. 17, 2024