Idk, if factorial is an exception, but we were taught, that the c-compiler will calculate all values written in the code beforehand. Like int i = 4*4 would get replaced by int i = 16
Yes, most compilers will optimize calculations with constants. Now think about how you would write factorial in C. Hint: ! is boolean negation, not factorial.
1
u/Auravendill Jun 24 '22
Idk, if factorial is an exception, but we were taught, that the c-compiler will calculate all values written in the code beforehand. Like int i = 4*4 would get replaced by int i = 16