指数类型问题(记住用API)

import java.util.Scanner;
import java.math.BigInteger;
// 1:无需package
// 2: 类名必须Main, 不可修改
public class Main {
public static void main(String[] args) {
BigInteger num = new BigInteger("1");
BigInteger sum = new BigInteger("1");
BigInteger t = new BigInteger("2");
for (int i = 0; i < 63 ; i++) {
num = num.multiply(t);
sum = sum.add(num);
}
System.out.println(sum);
}
}

BigInteger.multiply含义:乘法
BigInteger.add含义:加法
299

被折叠的 条评论
为什么被折叠?



