java中的while语句do…while语句

设有一张厚为0.2mm,面积足够大的纸,将它不断对折。试问对折多少次后,其厚度可达珠穆朗玛峰的高度(8843.8m)
(使用while语句)

建议自己想想怎么写,很有意思的题


double height = 0.0002 ; //初始厚度,单位转换为米

int count = 0while (height < 8843.8){
  height = height  *  2;//折一下
  count++; //计数
}
System.out.println("对折"+count+"次可达珠穆朗玛峰的高度");

public class count
{
private static double height = 0.0002;
private static int times = 0;
public static void main(String[] args)
{
while(height < 8843.8)
{
height *= 2;
times++;
}
System.out.println(times);
}
}

可以求对数,就不用循环了,纸张的厚度*2^n = 珠峰高度,相当于求 ㏒₂珠峰高度/纸张厚度,最后的结果取下一个整数,比如10.3要取11