递归算法:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class DiGui
{
//10!的阶乘s
public int Demo(int n)
{
//递归算法:自身调用自身
//递归一定要考虑递归的出口,不然就会造成死循环
if (n==1)
{
return 1;
}
return Demo(n - 1) * n;
}
//1 1 2 3 5 8 13 21 34 ........
//求第30位
//public int T(int n)
//{
//return
//}
}
}
和递归算法一个思路的自定义Math类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
nam