About this question
Medium · Code Analysis · Quant Trader interview question · python, recursion, optimization, tail-call
You are reviewing a Python script designed to efficiently calculate factorials for large numbers. The script utilizes a recursive function written in tail-call form. The goal is to understand whether Python's interpreter optimizes tail-recursive calls to prevent stack overflow errors when dealing with extremely large inputs. Consider the following scenario: The factorial function is defined recursively such that factorial(n) calls factorial(n-1) in the last operation of the function. This is con