- 纸张折叠成珠穆朗玛峰高度的次数
- class TestZhuFeng {
- /*
- 珠峰:8488
- 纸张厚度:0.01m
- 问:纸张对折多少次能达到珠峰高度?
- */
- public static void main(String[] args) {
- int count = getCount(0.01);
- System.out.println("对折次数:" + count);
- }
- public static int getCount(double height){
- int count = 0;
- while (height <= 8488.0) {
- height *= 2;
- count++;
- }
- return count;
- }
- }
复制代码 |
|