Nice! Did you include the math.h library? I am under linux, so the commands to compile were:

gcc -Wall -I/usr/local/include -c lnfactorial.c

and then:

gcc -L/usr/local/lib lnfactorial.o -lm -o lnfactorial

I have tried the following code and it worked like a charm:

Code:

#include <stdio.h>
#include <math.h>
int x;
double f;
double lnfactorial( int a);
int main(void)
{
printf("Enter an integer :");
scanf("%d" , &x);
f = lnfactorial(x);
printf("\nThe ln factorial of %d is %f\n", x, f);
return 0;
}
double lnfactorial( int a)
{
int y;
double z;
if (a == 1)
return 1;
else
{
z = 0;
for (y = 2; y<=a; y++ )
z = log(y)+z;
return (z);
}
}

On terminal, typing ./lnfactorial gives me, for example:

./lnfactorial

Enter an integer number:845123

The ln factorial of 845123 is 10688479.004670