SOURCE FILE: factorialA.cpp


/* This is a little program that exercises a non-recursive
   function that calculates factorials. */

#include <iostream.h>

int factorialA (int N)
{
  if (N<2) return 1;
  else 
  {
    int count, result=1;
    for (count=1; count<=N; count++)
       result = result * count ;
      return result ;
  }
}

int main ()
{
  cout << "Factorial(0) is: " << factorialA(0) << endl ;
  cout << "Factorial(1) is: " << factorialA(1) << endl ;
  cout << "Factorial(2) is: " << factorialA(2) << endl ;
  cout << "Factorial(3) is: " << factorialA(3) << endl ;
  cout << "Factorial(4) is: " << factorialA(4) << endl ;
  cout << "Factorial(5) is: " << factorialA(5) << endl ;
  cout << "Factorial(6) is: " << factorialA(6) << endl ;
  return 0 ;
}