Given an D-dimension array, where each axis is of length N, your goal is to find the sum of every index in the array starting from 0.

For Example if D=1 and N=10 then the answer would be 45 ([0,1,2,3,4,5,6,7,8,9])
If D=2 and N = 3 the answer is 18 which would be the sum of every number in the following:
```python
[
[(0,0), (0,1), (0,2)],
[(1,0), (1,1), (1,2)],
[(2,0), (2,1), (2,2)]
]
```

A naive solution could be to loop over every index in every dimension and add to a global sum. This won't work as the number of dimension is expected to be quite large.

Hint: A formulaic approach would be best
Hint 2: Gauss could solve the one dimensional case in his earliest of years, This is just a generalization.

~~~if:javascript
Note for JS version: Because the results will exceed the maximum safe integer easily, for such values you're only required to have a precision of at least `1 in 1e-9` to the actual answer.
~~~

Source: codewars | Difficulty: EASY
Tags: Mathematics

Ad-hoc

Starter code: def super_sum(D, N):
	

Solutions:
def super_sum(D, N):
	num = pow(N, D)
	dblAvg = D * (N - 1)
	return num * dblAvg // 2


def super_sum(D, N):
	return D * (N - 1) * N ** D // 2


def super_sum(d, n):
	return n ** (~-d) * n * ~-n * d >> 0 >> 1


def super_sum(D, N):
	return N ** D * D * ((N - 1) // 2) if N % 2 else N ** D // 2 * D * (N - 1)


super_sum = lambda d, n: (n - 1) * n // 2 * n ** (d - 1) * d


def super_sum(D, N):
	count = 0
	result = 0
	while N - 1 - count >= 1:
		result += (N - 1 - count) * N ** (D - 1)
		count += 1
	return result * D


def super_sum(D, N):
	summe = 0
	for i in range(0, N):
		summe += i
	erg = summe * D * N ** (D - 1)
	return erg