Easy calculation of simple asymetric table

18 Views Asked by At

This is a programming question, but very math specific, so I posted it here.
I have a value that ranges from 1 to 10.
1 = 1. This is irregular in math terms, but it has to start somewhere. Maybe you could say the starting value is 1 and 0 is added.
2 = 2, because it is the result from the value before (1) and 1 is added.
3 = 4, because it is the result from the value before (2) and 2 is added.
4 = 7, because it is the result from the value before (4) and 3 is added.
5 = 11, because it is the result from the value before (7) and 4 is added.
6 = 16, because it is the result from the value before (11) and 5 is added.
7 = 22, because it is the result from the value before (16) and 6 is added.
8 = 29, because it is the result from the value before (22) and 7 is added.
9 = 37, because it is the result from the value before (29) and 8 is added.
10 = 46, because it is the result from the value before (37) and 9 is added.

So the question would be: How can I put that most easily into a formula without putting the complete table inside? I think it would be independend from a programming language, except there are some specific libraries that calculate such things. Has anyone an idea about that?

So it would work in a formula like this:

var value1 = 4;
var value2 = 7;
var result = value1 * (value2 translated to the table value);
// var result = 4 * 22; And not 4 * 7

edit: The correct formula is a(n) = 1 + (n-1)*n/2