A mystery!
Exercise 1.18
Explain what the following algorithm does and give its cost as a function of n.
int mystery(int n) {
int f = 1;
for (int i = 2; i <= n; ++i)
*= i;
f return f;
}
Cum grano salis
Does the cost give a realistic running time? How many bits has the output as a function of n (asymptotically)? What is the cost actually measuring?