求几道有关VFP的题的答案
来源:学生作业帮 编辑:大师作文网作业帮 分类:数学作业 时间:2024/11/19 07:20:58
求几道有关VFP的题的答案
1.求[1,30]之间所有偶数的乘积;
2.已知S=1*2*2…*N,当S>800时退出,求此时最小的S值;
3.求S=1!+2!+…+n!
4.求S=1+1/(1!)+1/(2!)+…+1/(n!)
5.求Y=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+…+n)
谢谢!好的答案我会追加50分.
1.求[1,30]之间所有偶数的乘积;
2.已知S=1*2*2…*N,当S>800时退出,求此时最小的S值;
3.求S=1!+2!+…+n!
4.求S=1+1/(1!)+1/(2!)+…+1/(n!)
5.求Y=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+…+n)
谢谢!好的答案我会追加50分.
第一题:求[1,30]之间所有偶数的乘积.
clear
set talk off
i=1
s=1
do while i800时退出,求此时最小的N值.
clear
set talk off
i=1
s=1
do while .t.
s=s*i
if s>800
exit
endif
i=i+1
enddo
?"i=",str(i,1),"S=",str(s)
运行结果:i=7 , S=5040
第三题:求S=1!+2!+…+n! .
clear
set talk off
input "n= " to n
S=0
for i=1 to n
q=1
for j=1 to i
q=q*j
endfor
S=S+q
endfor
?S
第四题:求S=1+1/(1!)+1/(2!)+…+1/(n!)
clear
set talk off
input "n= " to n
S=1
for i=1 to n
q=1
for j=1 to i
q=q*j
endfor
S=S+1/q
endfor
?S
第五题:求Y=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+…+n)
clear
set talk off
input "n= " to n
S=0
for i=1 to n
q=0
for j=1 to i
q=q+j
endfor
S=S+1/q
endfor
?S
注:以上程序均在VFP6.0中调试通过.
以上答案不知是否符合追加50分的范畴哈.
clear
set talk off
i=1
s=1
do while i800时退出,求此时最小的N值.
clear
set talk off
i=1
s=1
do while .t.
s=s*i
if s>800
exit
endif
i=i+1
enddo
?"i=",str(i,1),"S=",str(s)
运行结果:i=7 , S=5040
第三题:求S=1!+2!+…+n! .
clear
set talk off
input "n= " to n
S=0
for i=1 to n
q=1
for j=1 to i
q=q*j
endfor
S=S+q
endfor
?S
第四题:求S=1+1/(1!)+1/(2!)+…+1/(n!)
clear
set talk off
input "n= " to n
S=1
for i=1 to n
q=1
for j=1 to i
q=q*j
endfor
S=S+1/q
endfor
?S
第五题:求Y=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+…+n)
clear
set talk off
input "n= " to n
S=0
for i=1 to n
q=0
for j=1 to i
q=q+j
endfor
S=S+1/q
endfor
?S
注:以上程序均在VFP6.0中调试通过.
以上答案不知是否符合追加50分的范畴哈.