示例
namespace RecursionExample
{
internal class Program
{
static void Main(string[] args)
{
double d = Sample.Factorial(5);
Console.WriteLine(d);
Console.ReadKey();
}
}
static class Sample
{
public static double Factorial(int number)
{
if (number == 0)
{
return 1;
}
else
{
return number * Factorial(number - 1);
}
}
}
}