Follow @dailycodedose.ai
Follow @dailycodedose.ai
• Purpose: This code is written to calculate factorial using recursion.
• Post-Decrement (n–): The value of n is sent to the function before it is reduced.
• Same Value Repeats: Because of this, the recursive call keeps receiving the same n again and again.
• Base Case Never Reached: Since n never actually decreases, the stopping condition is never met.
• Stack Overflow: Function calls keep piling up in memory until the stack gets full and crashes.
• Developer Verdict: Never use n– in recursive calls—always pass a clearly reduced value like n - 1.
Comments
Comments from the original post on Instagram
No comments yet
