Create a function to calculate the factorial of a given number using recursion.
Create a function to calculate the factorial of a given number using recursion.
Student
I am Utpal Vishwas from Uttar Pradesh. Have completed my B. Tech. course from MNNIT campus Prayagraj in 2022. I have good knowledge of computer networking.
Sure, here is the C# code to create a function to calculate the factorial of a given number using recursion:
C#
This function first checks if the given number is equal to 0. If it is, then the function returns 1. Otherwise, the function returns the product of the given number and the factorial of the number minus 1. The Main() method then reads a number from the user and calls the Factorial() function to calculate the factorial of the number. The result is then printed to the console.