如题

解决方案 »

  1.   

    楼主去这个帖子看以下吧!
    绝对有用的:
    “擂台赛:计算n!(阶乘)的精确值,速度最快者2000分送上(续)”
    http://topic.csdn.net/t/20031105/00/2427925.html
    50楼后就是代码分析了
      

  2.   

    表示的问题就很麻烦, 用 BigDec..?
      

  3.   

    ...用BigInteger到5000+ 就溢了
      

  4.   

    用java编了个程序,10000!就用了15秒。50000!算不出来。
      

  5.   

    呵呵,amd3000+、1G内存,计算50000!用了379093毫秒。实在佩服只用十几秒的强人。
      

  6.   

    http://topic.csdn.net/t/20020111/14/471898.html#,你可以参考一下
      

  7.   


    import java.math.BigInteger;
    public class TestCheng{
    public void testCheng(){
    BigInteger big = new BigInteger("1");
    for(int i=1;i<=50000;i++){
    big = big.multiply(new BigInteger(""+i));
    }
    System.out.println(big.toString());
    }
    public static void main(String[] args){
    new TestCheng().testCheng();
    }
    }
    AMD 3000+ 1.5G内存  用了49秒......
      

  8.   

    看似简单的问题背后的趣味不减啊 刚刚看到一篇讲的可以。
     高精度快速阶乘算法 :
    http://dev.csdn.net/article/29/29226.shtm
      

  9.   

    可以算出结果
    结果到word文档 小5字体  10页多一点
      

  10.   

    http://www.java2000.net
    里面有!
      

  11.   

    import java.util.Date;public class Factorial { public static void main(String[] args) {
    int N = Integer.parseInt(args[0]);
    int[] a = new int[N * 5];
    int n = N;
    int m = 0;
    int c = 0;
    int i = 0;
    Date start = new Date();
    a[0] = 1;
    for (; n > 1; n--) {
    for (c = i = 0; i <= m; i++) {
    a[i] = (c += a[i] * n) % 10;
    c /= 10;
    }
    while (c > 0) {
    a[++m] = c % 10;
    c /= 10;
    }
    }
    System.out.println(i);
    System.out.println(m);
    n = 0;
    for (; m >= 0; m--) {
    n = n + a[m];
    }
    System.out.println(n);
    Date end = new Date();
    System.out.println("冯冰:" + (end.getTime() - start.getTime()) + ":" + n);
    }
    }告诉大家一个方法可以硬性提高jvm速度  就是执行参数中加入 -server