home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff341.lzh / P2C / p2c.lzh / p2c1_13a / examples / fact.p < prev    next >
Text File  |  1990-03-09  |  299b  |  28 lines

  1.  
  2.  
  3. program factorials(input, output);
  4.  
  5.  
  6. var
  7.    i : integer;
  8.  
  9.  
  10.  
  11. function fact(n : integer) : integer;
  12.    begin
  13.       if n > 1 then
  14.          fact := n * fact(n-1)
  15.       else
  16.          fact := 1;
  17.    end;
  18.  
  19.  
  20.  
  21. begin
  22.    for i := 1 to 10 do
  23.       writeln('The factorial of ', i:1, ' is ', fact(i):1);
  24. end.
  25.  
  26.  
  27.  
  28.