Artificial intelligent assistant

Counting the Number of Reps From a Rep Height I'm trying to calculate the number of reps from a rep height. Example #1 Input: n = 2 Output: Result = 6 Because 1+2+2+1 = 6 \-- Example #2 Input: n = 3 Output: Result = 12 Because 1+2+3+3+2+1 = 12 What formula could I use to get from input to output?

My way before is unnecessarily long. When you add $(1 + 2 + \dots + n) + (n + (n-1) + \dots + 1)$, line up the pairs $(n, 1)$, $(2, n-1)$, $(3, n-2)$, and you'll notice that they all sum to $n+1$. Since you have $n$ pairs, the sum is $n(n+1)$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 98dd83b6822ef36fdbb27fd148f03601