赞
踩
假设一张纸的厚度是0.1mm,通过多少次折叠可以超过珠峰8848m。
- <!DOCTYPE html>
- <html lang="en">
-
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
-
- <body>
- <script>
- //while循环法
- var x = 0.0001, h = 8848, i = 0;
- while (x < h) {
- x *= 2;
- i++;
- }
- console.log("次数:" + i);
-
- //for循环
- var i = 0, h = 8848;
- for (x = 0.0001; x < h; x *= 2) {
- i++;
- }
- console.log("次数:" + i);
- </script>
- </body>
-
- </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。