Basic programming topic set 6-8 Simple factorial calculation (10 points)

Problem Description:

Problem solving ideas:

Since the data is small, it can be directly recursed

Problem solving code:

int Factorial( const int N ){
    if(N < 0) return 0;
    if(N == 0 || N == 1) return 1;
    else return N * Factorial(N-1);
}

Leave a Comment

Your email address will not be published. Required fields are marked *