S←1 For i from 1to4 S←S+2^iEND FOR Print S

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/29 22:48:58
S←1 For i from 1to4 S←S+2^iEND FOR Print S
x) ~6P-H!S!(?W$D$mPWlTOH X >;,+532m uZ YlΧ] vl @ aq8ȡ aakgbhٺ@!<

S←1 For i from 1to4 S←S+2^iEND FOR Print S
S←1 For i from 1to4 S←S+2^i
END FOR Print S

S←1 For i from 1to4 S←S+2^iEND FOR Print S
s=1;
i=1, s=1+2^1=3;
i=2, s=3+2^2=7;
i=3, s=7+2^3=15;
i=4, s=15+2^4=31;

所以打印 31

相当于等比数列求和,从2的0次方加到2的4次方
S=1+2^1+2^2+2^3+2^4=(1*(1-2^5))/(1-2)=2^5-1=31