// lang_fak.cc
// Fakultaetsberechnung mit Langzahlen:
// Compilation mit:  g++ lang_fak.cc -lgmpxx -lgmp
#include <gmpxx.h>
#include <iostream>
#include <iomanip>
using namespace std;

typedef mpz_class Int;

template <class T>
T fak (T i) {
  if ( i <= 1 ) return 1;
  T r = 2;
  while (i > 2) r *= i--;
  return r;
}

// Rekursives Template cf. lang_fac_rec.cc
// Interessant hier die Eingabe i = 10000.

int main() {
  unsigned int i; Int k;
  cout << "Eingabe : ";
  cin  >> i;
  cout << "Fuer long long   : ";
  cout << i << "! = "  << fak( (unsigned long long)   i) << "\n";
  cout << "Fuer long double : ";
  cout << i << "! = " << fak( (long double) i) << "\n";
  cout << "Fuer Int         : ";
  cout << i << "! = "  << fak ( (Int) i )      << "\n";
}
