Ask Your Question

Revision history [back]

You can always do

sage: dings = [1 , 2, 3, 4, 5]
sage: length = len(dings)
sage: sum([1/dings[k] for k in range(length)])

or

sage: var('k')
sage: d(k) = 1/k  # defines d to be a (symbolic) function
sage: sum(d(k), k, 1, 5)

The second version works more generally:

sage: var('k')
sage: d(k) = 1/k^2
sage: sum(d(k), k, 1, infinity)
1/6*pi^2