0
I don't know how we got 24
The code is like this: function p(m){ If(m ==1) { return m; } Else { return m * p(m -1) } } alert (p(4)); I used maths like m=4, m*p(m-1) =4*(4-1), which gives me 12 and it is wrong
2 ответов
+ 4
Handtrace it! :>
p(4)
4 * p(3)
4 * 3 * p(2)
4 * 3 * 2 * p(1)
4 * 3 * 2 * 1
= 24
You were halfway there but you stopped expanding at p(4-1).
+ 1
Thank you Fermi