Advanced
Refactor Python Function
Improve the efficiency and readability of a given Python code snippet.
📝 Treść promptu
Refactor the following Python code to be more efficient and Pythonic. Add type hints and a docstring. The function calculates the factorial of a number using a basic loop. [Insert Code Here: def factorial(n): result = 1; for i in range(1, n+1): result *= i; return result]