1 文本格式
/// <summary>
/// 《小白学程序》第二十四课:大数(BigInteger)的阶乘
/// 用于大数的阶乘算法(原始算法)
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
public static string big_integer_fractial_original(string a)
{
string r = "1";
while (a != "1" && a != "0")
{
r = big_integer_multiply(r, a);
a = big_integer_subtract(a, "1");
}
return r;
}
/// <summary>
/// 《小白学程序》第二十四课:大数(BigInteger)的阶乘
/// 用于大数的阶乘算法(递归算法)
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
public static string big_integer_fractial(string a)
{
if (a != "1" && a != "0")
return big_integer_multiply(a, big_integer_fractial(big_integer_subtract(a, "1")));
else
return "1";
}
2 代码格式
/// <summary>
/// 《小白学程序》第二十四课:大数(BigInteger)的阶乘
/// 用于大数的阶乘算法(原始算法)
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
public static string big_integer_fractial_original(string a)
{
string r = "1";
while (a != "1" && a != "0")
{
r = big_integer_multiply(r, a);
a = big_integer_subtract(a, "1");
}
return r;
}
/// <summary>
/// 《小白学程序》第二十四课:大数(BigInteger)的阶乘
/// 用于大数的阶乘算法(递归算法)
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
public static string big_integer_fractial(string a)
{
if (a != "1" && a != "0")
return big_integer_multiply(a, big_integer_fractial(big_integer_subtract(a, "1")));
else
return "1";
}