用
C#
编写一个方法,求
1000
!。用
javascript
调用该方法并输出结果,同时绑
定该方法到
Label
控件并显示结果,如图
30
所示。(提示,因
1000
!结果太大,可采用
BigInteger
来求解)
C#求n!(n的阶乘)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Factorial
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入一个整数:");
long n = long.Parse(Console.ReadLine());
long i=1;
long result=1;
while(i<=n)
{
result *= i;
i++;
}
Console.WriteLine("{0}!={1}",n,result);
Console.ReadLine();
}
}
}
http://www.cnblogs.com/snowdust/archive/2010/03/18/1688963.html
参考,里面的ToString方法就是得到结果,你显示在label
楼上的代码做成一个方法,用ajax传递你客户端输入的数字到服务器端计算就行,
http://www.w3school.com.cn/jquery/ajax_ajax.asp