0

Factorial

I Came across with an example of a factorial function that I didn't get. What does "total *= x" and "x-=1" mean? It's an exercise in code academy if it's relevant. Thanks

27th Aug 2019, 5:43 AM
Liat123
Liat123 - avatar
1 ответ
+ 6
This 2 expressions are so called inplace operator and a kind of shortcut total *= x is the same as: total = total * x x-=1 is the same as: x = x - 1 Behind the scene there can be some differences as explained here: https://stackoverflow.com/questions/15376509/when-is-i-x-different-from-i-i-x-in-JUMP_LINK__&&__python__&&__JUMP_LINK
27th Aug 2019, 6:00 AM
Lothar
Lothar - avatar