# How can I sum (multiply ...) all elements on the calc stack?

Sometimes I just want to sum a bunch of numbers in calc. Right now I press `+` until the stack is empty. Is there a shorthand for this?

• You can use the prefix `C-u`, followed by the number of entries on the stack, followed by the symbol of the calculation. Feb 6 '20 at 15:08

Another solution, if you know from the beginning that you want a sum, is use a vector. Prefix your list of numbers with `[`, finish with `]`, and sum using `calc-reduce` with the `+` operator (`v R +`):

``````[
1
2
...
]
v R +
``````

Summing the whole stack of calc can be achieved using a keyboard macro.

• Define the macro (which does just the `+` operation): `C-x ( + C-x )`.
• BTW this definition already sums two elements of the stack as a side effect.
• Then run the macro until an error occurs with `C-0 X`.
• That's it! The error is expected to occur when one element remains on the stack.

If you know the stack size you possibly better use the suggestion of swedgin.

• I think both answers are valid. However I can only accept one. But both get an upvote! :)
– Arne
Feb 11 '20 at 14:53