Java编程算法基础---使用大整数

来源:互联网 发布:起个网络名字大全女孩 编辑:程序博客网 时间:2024/06/06 04:59

java提供了大整数类来表达任意大小的整数。这在进行大数值精确运算时很有用。

 

 

package NO5;import java.math.BigInteger;public class Test12 {public static void main(String[] args) {// TODO Auto-generated method stub        //BigInteger a = BigInteger.ONE;   BigInteger a = BigInteger.valueOf(1);        for(int i = 1; i <=10;i++){        a = a.multiply(BigInteger.valueOf(i));            //System.out.println(a);        }System.out.println(a);}}


 

0 0