
x>0时,y=x的3次方
x=0时,y=0
x<0时,y=2x
2.编写程序计算数列1!,2!,3!,…,n!的前n项之和,即1!+2!+3!+…+n!。其中n的值从键盘输入。
1
clear
input "x=" to x
if x>0
y=x^3
elseif x=0
y=0
else
y=2*x
endif
?"数凳轮y="粗孝,y
return
2
clear
s=0
input "n=",n
for i=1 to n
p=1
for j=1 to i
p=p*j
endfor
s=s+p
endfor
?"薯信1!+2!+3!+…+n!=",s
return