I was wondering what a tail recursive factorial function would look like. In one of my lectures they said it should be pretty easy to implement, but I cant imagine how to implement it.
Thanks in advance!
I was wondering what a tail recursive factorial function would look like. In one of my lectures they said it should be pretty easy to implement, but I cant imagine how to implement it.
Thanks in advance!
 
    
    Just a basic C snippet:
unsigned int factorial(unsigned int n){
    if(n == 0){
        return 1;
    }
    else{
        return n * factorial(n - 1);
    }
}
Here, factorial() function is calling factorial() function again i.e. recursion.
