Understanding the Code
s = 1: Initial value of s.
range(1, 4) → iterates over i = 1, 2, 3.
The update in the loop is:
Which is the same as:
🔄 Step-by-step Execution
🧮 Iteration 1 (i = 1)
🧮 Iteration 2 (i = 2)
🧮 Iteration 3 (i = 3)
✅ Final Output
🧠 Shortcut Insight:
You’re actually computing:
That’s 1 × 2 × 3 × 4 = 24, so it's calculating 4! (factorial of 4).






.png)
.png)




.png)

.png)




.png)
.png)

