teplohod's blog

By teplohod, history, 13 months ago, In Russian
from math import factorial

def exotic_formula(n):
    """
    Returns the value of the exotic formula for a given integer n.
    """
    result = 0
    for i in range(n):
        result += (-1)**i * factorial(n) // (factorial(i) * factorial(n-i) * (2*i+1))
    return result

Эта формула вычисляет значение следующей суммы: ∑i=0n−1(−1)in!i!(n−i)!(2i+1) i=0∑n−1​i!(n−i)!(2i+1)(−1)in!​

  • Vote: I like it
  • +2
  • Vote: I do not like it