<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
// 假设一张纸为0.01米 对折多少次后能比珠穆朗玛峰高
var mountain = 8848;
var paper = 0.01;
for (var i = 1; i < 100; i++) {
paper *= 2;
if (paper >= mountain) {
console.log(i);
break;
}
}
var mountain = 8848;
var paper = 0.01;
var i = 1;
while (i < 100) {
paper = paper * 2;
if (paper >= mountain) {
console.log(i);
break;
}
i = i + 1;
}
let j;
j = 0;
for(let i = 0.01; i<=8848;i+=i){
j++
console.log(i);
}
console.log(j)
let i;
j=1
for(let i = 0.01; i<=8884; i+=i){
j++
console.log(i)
}
console.log(j)
</script>
</body>
</html>
js数组计算假设一张纸为0.01米 对折多少次后能比珠穆朗玛峰高
最新推荐文章于 2024-09-07 13:38:28 发布