josecarlosgutierrez2002@gmail.com

 avatar
Jose20025
c_cpp
3 years ago
421 B
8
Indexable
#include <iostream>

using namespace std;

int FAC(int numero);

int main() {

  int numero;

  system("cls");
  cout << "Digite el numero: ";
  cin >> numero;

  cout << "\nEl resultado es: " << FAC(numero) << endl;

  return 0;
}

int FAC(int numero) {
  int factorial = 1;

  if (numero != 0) {
    for (int i = 1; i <= numero; i++) {
      factorial *= i;
    }
  }

  return factorial;
}