static void Main() { int num; Console.WriteLine("请输入一个整数:"); num = Convert.ToInt32(Console.ReadLine()); Factorial n = new Factorial(); int result; result = n.Execute(num); Console.WriteLine(result); Console.ReadLine(); }
private void button1_Click(object sender, EventArgs e) { int num = Convert.ToInt32(txtdg.Text); Stopwatch sw = new Stopwatch(); sw.Restart(); Factorial factorial = new Factorial(num); txtRs.Text = factorial.ToString(); sw.Stop(); labMsg.Text = "耗时:" + sw.Elapsed.TotalSeconds.ToString(); }
public void ZeroFactorial_Test() { Factorial factorial = new Factorial(); Assert.AreEqual(0, factorial.compute(0)); }
public void TwoFactorial_Test() { Factorial factorial = new Factorial(); Assert.AreEqual(2, factorial.compute(2)); }
public void OneFactorial_Test() { Factorial factorial = new Factorial(); Assert.AreEqual(1, factorial.compute(1)); }