home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / interpre / liberty / os2 / factoril.bas < prev    next >
BASIC Source File  |  1993-11-22  |  436b  |  26 lines

  1.  
  2.     'this program computes a factorial for a keyboard entered
  3.     'number and displays the result
  4.  
  5.     input "Please enter a number>"; entry
  6.  
  7.     result = 1
  8.  
  9. [recurringLoop]
  10.  
  11.     counter = counter + 1
  12.     if counter > entry then [skip]
  13.     result = result * counter
  14.     gosub [recurringLoop]
  15.  
  16. [skip]
  17.  
  18.     entry = entry - 1
  19.     if entry = 1 then [end]
  20.     return
  21.  
  22. [end]
  23.  
  24.     print "The factorial is: "; result
  25.  
  26.