#include <iostream>

using namespace std;

int main() {
    int numero;
    long long factorial = 1; // Usamos long long por si N es grande
    
    cout << "Numero: ";
    cin >> numero;
    
    if (numero < 0) {
        cout << "El factorial no esta definido para negativos." << endl;
    } else {
        for (int i = 1; i <= numero; i++) {
            factorial *= i;
        }
        
        cout << numero << "! = ";
        if (numero == 0) {
            cout << "1";
        } else {
            for (int i = numero; i >= 1; i--) {
                cout << i;
                if (i > 1) cout << " x ";
            }
        }
        cout << endl;
        cout << "Resultado: " << factorial << endl;
    }
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: