/* gamma.c Last Modified 10/20/98 */ /* Evaluate gamma function at integer and */ /* 1/2 integer increments FOR SMALL ARGUMENTS! */ #include double gamma(double x) { double y, a; double sqrtpi=1.7724538509055159; a=x; y=1.0; while (x>0){ if(x>1) y=y*(x-1); else if(x==1) y=y; else if (x==0.5) y=y*sqrtpi; else{ printf("ERROR: gamma can only be used with integer and 1/2 int arguments\n"); printf("ERROR: argument was = %5.2e\n",a); exit(-1); } x=x-1; } return(y); } /* end of gamma */