Ask Your Question

Revision history [back]

You could use Python's list comprehension to make a list of the numbers you want:

sage: N = 5
sage: [(-1)^(n+1)*floor((n+1)/2) for n in range(N)]
[0, 1, -1, 2, -2]
sage: N = 6
sage: [(-1)^(n+1)*floor((n+1)/2) for n in range(N)]
[0, 1, -1, 2, -2, 3]

Is this the kind of thing you were looking for, or something else?