i hadnt considered it until pycoucou posted but 1000! is a 2568 digit number so you would definatly need an arbitrary length integer library. if time wasnt a constraint i would probably do something like
Code:
big_num_t x=1;
for(int n=1;n<1001;n++) {
x*=n;
if(x != factorial(n)) break;
}
if(n!=1001) printf("failed on %d", n);
you could do lots of quick tests all of which are necessary but not sufficient for the function to be correct and if they all pass then its likely the program is correct. eg
a) does it have the correct number of digits
b) are the last couple of digits correct
c) does it have some factors it should
d) does it have a factor it shouldnt
e) do the digits sum correctly (multiple of 3 for n>=3 multiple of 9 n>=6)
...
with a bit of number theory im sure you can come up with more conditions of you wish.
if you have a quick way to work out the gamma function then it might be worth comparing it to that as well. a digit extraction algorithm would be nice but unfortunatly there doesnt seem to be one.
cant really think of anything else.