用python输出等差数列
x1 = 1
d = 3
n = 100
print 'xn = x1 + (n-1)d'
x100 = x1+(n-1)*d
print 'x100 =',x100
print 's = nx1 + n*(n-1)*d/2'
s = n*x1 +n*(n-1)*d/2
print s
x1 = 1
d = 3
n = 100
print 'xn = x1 + (n-1)d'
x100 = x1+(n-1)*d
print 'x100 =',x100
print 's = nx1 + n*(n-1)*d/2'
s = n*x1 +n*(n-1)*d/2
print s
2017-02-27
举报