如题。1,比较简单的算法。2,效率高的算法。

解决方案 »

  1.   

    import java.math.* ;public class Test
    {
    BigInteger sum = new BigInteger("0") ;
    BigInteger tmp = new BigInteger("1") ;

    public static void main( String args[] )
    {
    Test t = new Test() ;
    for ( int i = 1; i<=100; i++ )
    {
    BigInteger ii = new BigInteger( new Integer(i).toString() ) ;
    t.add( ii ) ;
    }
    System.out.println (t.sum.toString()) ;
    }

    public void add( BigInteger bi )
    {
    tmp = tmp.multiply( bi ) ;
    sum = sum.add( tmp ) ;
    }
    }不知道是不是和你的要求