我正在尝试使我的 Hailstone 序列输出由于 int 的限制而无法计算的最小整数,但由于某种原因它仍然无法正常工作。关于为什么不这样做的任何想法将不胜感激。
public static void main(String[] args) {
int x=2;
int count = x;
//Collatz Conjecture computation
while (true)
{ x=2;
x =count;
while (x != 1)
{
if (x % 2 == 0)
x = x / 2;
if (x % 2 == 1)
x = x * 3 + 1;
if (x < 0)
{ System.out.print("The integer " + count + " cannot have its Hailstone sequence computed using int variables. ");
return;
}
}
count ++;
}
}