以下是我BigInteger
的代码,我不知道哪里出错了,有人可以请更正我的代码吗?
import java.math.BigInteger;
import java.util.Scanner;
public class Class2 {
public static void main(String[] args) {
Scanner num = new Scanner(System.in);
System.out.println("Enter BigInteger number : ");
BigInteger nbn = num.nextBigInteger();
for(BigInteger count = BigInteger.ZERO;
count.compareTo(nbn) <= 0;
count.add(BigInteger.ONE)) {
System.out.println(count);
}
}
}
答案 0 :(得分:5)
将count.add(BigInteger.ONE)
的值分配回count
:
for (BigInteger count = BigInteger.ZERO;
count.compareTo(nbn) <= 0;
count = count.add(BigInteger.ONE)) {
System.out.println(count);
}