function d (k, n) {
    let S = k
    for (let j = k; smallerEq(j, n); j = add(j, 1)) {
      const factor = divide(
        multiply(factorial(add(n, subtract(j, 1))), pow(4, j)),
        multiply(factorial(subtract(n, j)), factorial(multiply(2, j)))
      )
      S = add(S, factor)
    }

    return multiply(n, S)
  }
Calculate a portion of the sum
@param {number | BigNumber} k   a positive integer
@param {number | BigNumber} n   a positive integer
@return {number}    the portion of the sum