/* Copyright (C) 1994 by Thomas Glen Smith. All Rights Reserved. */ /* ifactorp 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" void ifactorp(n,ret) int *n,*ret; { extern int aplerr; int i,j,k; j = *n; if (j == 0 || j == 1) { *ret = 1; return; } if (j < 0.0) { aplerr = 36; /* bad argument to factorial */ *ret = 0; return; } i = j; while (--i) j *= i; *ret = j; }