for迴圈計算公式
撰寫一個for迴圈計算下列公式,然後將結果顯示在網頁上:
(1/2)^1+(1/2)^2+(1/2)^3+(1/2)^4+(1/2)^5+(1/2)^6+(1/2)^7+(1/2)^8
輸出結果:
(1/2)^1+(1/2)^2+(1/2)^3+(1/2)^4+(1/2)^5+(1/2)^6+(1/2)^7+(1/2)^8
=0.5+0.25+0.125+0.0625+0.03125+0.015625+0.0078125+0.00390625= 0.99609375
(1/2)^1+(1/2)^2+(1/2)^3+(1/2)^4+(1/2)^5+(1/2)^6+(1/2)^7+(1/2)^8
輸出結果:
(1/2)^1+(1/2)^2+(1/2)^3+(1/2)^4+(1/2)^5+(1/2)^6+(1/2)^7+(1/2)^8
=0.5+0.25+0.125+0.0625+0.03125+0.015625+0.0078125+0.00390625= 0.99609375
留言
張貼留言