You can't put one function inside another function. Here is an example of how it should be done (C++):

PHP Code:
//This includes files needed for basic output to the screen
#include <iostream>
using namespace std;

//if the implementation of the function comes after the call, it needs to be declared first
int factorial(int iNumber);

//this is the application's main function
int main() 

    
cout << "the factorial of 5 is: " << factorial(5); //call the function, and output to the screen
    
return 0;


//Calculates the factorial of a number
int factorial(int iNumber)

    if (
iNumber==0
        return 
1
    else 
        return 
factorial(iNumber-1);//this is what makes it recursive