topical media & game development

talk show tell print

basic-program-solutions-05-Soln5-1.c

? / basic-program-solutions-05-Soln5-1.c


  // Soln5_1.cpp
  include <iostream>
  using std::cout;
  using std::endl;
  
  // Recursive factorial function
  long fact(long n)
  {
    return n == 1L ? 1L : n*fact(n-1);
  }
  
  int main()
  {
    for(long value = 2 ; value<10L ; value++)
      cout << value << "! = " << fact(value) << endl;
  
    return 0;
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.