#include #include using namespace std; // iterative method factorial unsigned long factorial( unsigned long number ) { unsigned long result = 1; // iterative factorial calculation for ( unsigned long i = number; i >= 1; i-- ) result *= i; return result; } // end function factorial int main() { // calculate the factorials of 0 through 10 for ( int counter = 0; counter <= 25; counter++ ) cout << setw( 2 ) << counter << "! = " << factorial( counter ) << endl; system("pause"); return 0; } // end main