Category : Files from Magazines
Archive   : DDJ8702.ZIP
Filename : BASICEX.LST

 
Output of file : BASICEX.LST contained in archive : DDJ8702.ZIP



MODULE Factorial

PUBLIC Last_Fact ! Global variable
PRIVATE Bad_Number ! Local routine
DECLARE DEF Bad_Number ! Function declaration
SHARE Fact_Array(30), Product, MAX ! Local static variables

!------------ Initialize module -----------
let MAX = 30
let Last_Fact = Bad_Number
let Product = Bad_Number
IF MAX > 30 THEN MAT REDIM Fact_Array(MAX) ! Adjust array size
let Fact_Array(1) = 1
FOR I = 2 TO MAX
let Fact_Array(I) = I * Fact_Array(I-1)
NEXT I

!------------ LOCAL ROUTINES --------

DEF Bad_Number = -1.0E+200

!------------ EXPORTED ROUTINES -----

DEF Fact(N)

IF (INT(N) - N) <> 0 THEN
let Fact = Bad_Number
ELSE
let Last_Fact = Product

IF N <= MAX THEN
let Product = Fact_Array(N)
ELSE
let Product = Fact_Array(MAX)
FOR I = MAX+1 TO N
let Product = I * Product
NEXT I

END IF
let Fact = Product
END IF
END DEF

END MODULE



  3 Responses to “Category : Files from Magazines
Archive   : DDJ8702.ZIP
Filename : BASICEX.LST

  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/