home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / ACE / Prgs / Misc / fact.b < prev    next >
Text File  |  1994-01-10  |  301b  |  17 lines

  1. '...factorial (calculated recursively).
  2. '...note that 0! = 1 by definition.
  3.  
  4. defsng f,n,x
  5.  
  6. sub fact(n)
  7.   if n<2 then fact=1 else fact=n*fact(n-1)
  8. end sub
  9.  
  10. repeat
  11.   print
  12.   repeat
  13.     input "Enter an integer (0 or higher, -1 to stop): ",x
  14.   until x>=-1
  15.   if x<>-1 then print "--->>";fact(x)
  16. until x=-1
  17.