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.
250
14-Jun-2023
Aryan Kumar
15-Jun-2023Sure, 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.