Metropoli BBS
VIEWER: ifactorl.c MODE: TEXT (ASCII)
/*Copyright (C) 1992, 1996 by Thomas Glen Smith.  All Rights Reserved.*/
/* ifactorl APL2 V1.0.0 ************************************************
* For positive integers, ifactorl(n) is defined as the product of all  *
* positive integers up to n.  Factorl(0) and factorl(1) both return 1. *
* If argument n is a negative integer, aplerr will be set.             *
***********************************************************************/
#define INCLUDES 0
#include "includes.h"
int ifactorl(n)
int n;
{
	extern int aplerr;
	int i,j;

	j = n;
	if (n==0 || n==1) return(1);
	if (n < 0.0) {
		aplerr = 36; /* bad argument to factorial */
		return(0);
		}
	j = n;
	while (--n) j *= n;
	return(j);
}
[ RETURN TO DIRECTORY ]