Category : OS/2 Files
Archive   : REXEXMPL.ZIP
Filename : FACTOR.CMD

 
Output of file : FACTOR.CMD contained in archive : REXEXMPL.ZIP
/* */
/* Factors a positive integer. */
/* */
/* Written by James L. Dean */
/* 406 40th Street */
/* New Orleans, LA 70124-1532 */
/* */
ARG number_to_be_factored
IF number_to_be_factored = '' THEN
SAY 'Error: a positive integer must be specified as an argument.'
ELSE
IF VERIFY(number_to_be_factored,'0123456789') = 0 THEN
DO
TRUE='1'
FALSE='0'
SAY 'Factors:'
IF number_to_be_factored = 1 THEN
SAY ' 1'
ELSE
DO
IF LENGTH(number_to_be_factored) > 9 THEN
NUMERIC DIGITS LENGTH(number_to_be_factored)
left_to_be_factored=number_to_be_factored
upper_limit=left_to_be_factored
finished=FALSE
DO WHILE (\ finished)
x2=(left_to_be_factored%upper_limit+upper_limit)%2
IF x2 < upper_limit THEN
upper_limit=x2
ELSE
finished=TRUE
END
possible_factor=2
DO WHILE (possible_factor <= upper_limit)
quotient=left_to_be_factored%possible_factor
product=quotient*possible_factor
IF product = left_to_be_factored THEN
DO
SAY ' '||possible_factor
left_to_be_factored=quotient
upper_limit=left_to_be_factored
finished=FALSE
DO WHILE (\ finished)
x2=(left_to_be_factored%upper_limit+upper_limit)%2
IF x2 < upper_limit THEN
upper_limit=x2
ELSE
finished=TRUE
END
END
ELSE
IF possible_factor = 2 THEN
possible_factor=3
ELSE
possible_factor=possible_factor+2
END
IF left_to_be_factored > 1 THEN
SAY ' '||left_to_be_factored
END
END
ELSE
SAY 'Error: a positive integer must be specified as an argument.'



  3 Responses to “Category : OS/2 Files
Archive   : REXEXMPL.ZIP
Filename : FACTOR.CMD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/