64格棋盘,第一格放一粒芝麻,重0.00001KG,第二格放两粒芝麻,第三格放4个芝麻,求棋盘上芝麻总重。
<!DOCTYPE html
>
<html lang
="en">
<head
>
<meta charset
="UTF-8">
<meta name
="viewport" content
="width=device-width, initial-scale=1.0">
<meta http
-equiv
="X-UA-Compatible" content
="ie=edge">
<title
>Document
</title
>
</head
>
<body
>
<input type
="button" value
="重量" onclick
="testf()">
</body
>
</html
>
<script
>
function testf(){
var x
=0 ;
for(var i
=1;i
<=64;i
++){
x
=x
+Math
.pow(2,i
-1);
}
var y
=x
*0.00001;
document
.write(y
);
}
</script
>
转载请注明原文地址: https://mac.8miu.com/read-495723.html