home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
TOOLKIT
/
CREXX
/
REXXCALC
/
PROGRAM1.CAL
< prev
next >
Wrap
Text File
|
1994-11-17
|
1KB
|
25 lines
/* Rexx Calculator program 1 key - factorial */
parse arg left, right /* get the two operands */
numeric digits CalcPrecision() /* set current precision */
numeric form value CalcForm() /* set current form */
if left < 0 /* valid for factorial ? */
then return 'Error' /* return error indicator */
if \datatype(left, 'Whole') /* must be whole number too */
then return 'Error' /* return error indicator */
if left > 100 then do /* this might take a while */
ans = rxmessagebox(left 'Factorial may take a long time. Continue?',,
'Factorial', 'YesNo', 'Query')
if ans <> 6 then return left /* just quit if no */
end
accumulator = 1 /* set start value */
do i = 2 to left /* loop through factorial */
accumulator = accumulator * i /* multiply next factor */
end
return accumulator /* finished */