Please explain to me how this code work so it make sense to me.

Code:

#include <iostream>

using namespace std;

double factorial ( double a )

{

if (a > 1 )

return ( a * factorial (a -1) );

else

return (1);

}

int main()

{

double num;

cout << "Enter a number: ";

cin >> num;

cout << num << "! = " << factorial(num);

system("pause");

return 0;

}

Now I know that the working for factorial is

n! = n * ( n - 1) * ( n - 2) * ( n - 3) .... * 1

but I can't see how this is implemented on the code.

Please help me to understand the code. Thanks.