In the general case, when you have O (N 4 ), you also need to enter the terms for O (N 3 ), O (N 2 ), O (N) and O (1). In other words, try adding x 3 x 1 and x 0 to the curve fitting model.
In this particular case, when you have O (N!), I would follow the advice and consider only the factorial part, since it seems to converge quite quickly.
But in any case, if you really have O (N!), You do not need to evaluate, just use the iterative deepening approach. Let your computer iteratively run the case for n = 1,2,3,4,5,6,7 ... and let it go as far as possible.
It may seem that you are wasting time on your computer time, but if you analyze it, you will see that the wasted time is negligible. For example, you are already at n = 12, so for n = 13 the required CPU C 13 will be 13 * C 12 , C 12 = 12 * C 11 and so on. Introducing your measurements, summarize (C 13 .. C 0 ) / C 13 = 1.082, so running your function for all values from 0 to 13 will cost 8% more than just running it at 13. And as you go to large N values, this percentage will be further softened.
Update
Why you need to add terms for all capacities below the difficulty level:
Consider a simple three-level cycle with complexity O (N 3 ):
void foo(int n) { int i, j, k; for (i = 0; i < n; i++) for (j = 0; j < n; j++) for (k = 0; k < n; k++) do_something(i, j, k); } foo(3);
Obviously, do_something(i, j, k) is called n 3 times.
But we start from the very beginning, considering each executed command, we can see how to enter and leave the function, setting the stack and other low-level tasks that are performed once; the i=0 instruction is also executed once. These are instructions corresponding to a cost of n 0 .
The instructions i < n , i++ and j=0 are called n times; they correspond to the term n 1 .
The instructions j < n , j++ and k=0 are called n 2 times; they correspond to the term n 2 .
Well, etc.
More complex cases are the same, you always have commands that are executed several times in proportion to all capacities below the level of complexity.
As for your measurement, C(0) = 0 , it's just a problem of your timings, which are not accurate enough. It can be very small, but not absolute 0.
And finally, if your curve fitting doesn't work, it's because of N! since in this case you will also follow instructions (n-1)! times and (n-2!) times, etc.