home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 247_01 / fact.cpp < prev    next >
Text File  |  1989-04-19  |  512b  |  20 lines

  1. /*
  2.  *   Program to calculate factorials.
  3.  */
  4.  
  5. #include <stream.hpp>
  6. #include "big.hpp"   /* include MIRACL system */
  7.  
  8. miracl precision=100;
  9.  
  10. main()
  11. { /* calculate factorial of number */
  12.     Big nf=1;           /* declare "Big" variable nf */
  13.     int n;
  14.     cout << "factorial program\n";
  15.     cout << "input number n= \n";
  16.     cin >> n;
  17.     while (n>1) nf*=(n--);   /* nf=n!=n*(n-1)*(n-2)*....3*2*1  */
  18.     cout << "n!= \n" << nf << "\n";
  19. }
  20.