/* 
 * Michael Gousie
 * COMP 318  Spring 2026
 * fact.cpp
 *
 * Find n!, where n is input.
 * This version also counts number of operations.
 */

#include<iostream>
using namespace std;

int counter;  // number of ops

int fact (int n) {
   if (n == 0 || n == 1) {
      counter++;
      return 1;
   }
   else {
      counter++;
      return n * fact (n-1);
   }
}


int main () {
   int x;
   counter = 0;

   cout << "Enter x: ";
   cin >> x;
   cout << "x! = " << fact (x) << endl;
   cout << counter << endl;

   return 0;
}
