递归算法阶乘:
class Program
{
public static double jiecheng(int a)
{
if (a ==0)
{
return 1;
}
return a * jiecheng(a - 1);
}
static void Main(string[] args)
{
Console.WriteLine(jiecheng (10));
递归加法
public static int age(int n)
{
int c;
if (n ==1)
{
c = 10;
}
else
{
c = age(n - 1) + 2;
}
return c;
}
static void Main(string[] args)
{
Console.WriteLine("******" + age(5));