用递归求阶乘
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace DiGui { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write("3的阶乘为:" + DiGui(3).ToString()); } private int DiGui(int n) { if (n == 0 || n == 1) return 1; else return n * DiGui(n - 1); } } }